http://www.combustory.com/wiki/index.php?title=Special:Contributions&feed=atom&deletedOnly=&limit=50&target=Jvaughters&topOnly= Combustory - User contributions [en] 2024-03-29T07:13:38Z From Combustory MediaWiki 1.17.0 http://www.combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev Arduino Communications Device Naming with udev 2019-03-04T18:08:31Z <p>Jvaughters: /* udev */</p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> __NOTOC__<br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> {{Article summary start}}<br /> {{Article summary text|This article covers the configuration of udev for Arduino Communication.}}<br /> {{Article summary end}}<br /> <br /> ==Summary==<br /> If you use more than one Arduino with USB or have other USB-to-Serial devices, then you may find it convenient to make the device have the same name every time you reboot or connect the Arduino. The technique here is shown for an FTDI device, but the same process can be used for just about any USB-to-Serial device that the system recognizes.<br /> <br /> ==Assumptions==<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> <br /> ==Installation==<br /> <br /> {{Note|All scripts will assume that there is a '{{ic|/dev/arduino_1}}'.}}<br /> <br /> The drivers for the FTDI chip is included in the kernel, so it should be detected as soon as it's plugged in, and assigned to device {{ic|/dev/ttyUSB[0-9]}}.<br /> To check where it got assigned, run:<br /> <br /> dmesg | grep FTDI<br /> <br /> The output will contain a line that looks something like this:<br /> <br /> usb 1-4.4: FTDI USB Serial Device converter now attached to ttyUSB0<br /> <br /> ===udev===<br /> <br /> It can be annoying to have to look up what {{ic|/dev/ttyUSB[0-9]}} the device gets assigned, so it's a good idea to add a simple udev rule that creates a link to the device when it is plugged in. It used to be possible to rename the device which would leave the ttyUSB[0-9] open for other devices. If you are using a linux kernel that is old enough you can rename the device. However, the linux community has determined the link is the proper method to track the device. Below I will show both methods.<br /> <br /> First of all, you will need to find out the serial number of FTDI chip on the Arduino. This can be achieved by running the following, assuming your device is plugged in and was assigned to {{ic|/dev/ttyUSB0}}:<br /> <br /> udevadm info --attribute-walk -n /dev/ttyUSB0<br /> <br /> Now add/create the following file:<br /> <br /> /etc/udev/rules.d/98-arduino.rules<br /> <br /> For the old kernels put this in your file:<br /> <br /> &lt;pre&gt;&lt;nowiki&gt;<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;XXXXXXXX&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> &lt;/nowiki&gt;&lt;/pre&gt;<br /> <br /> For the new kernels put this in your file:<br /> <br /> &lt;pre&gt;&lt;nowiki&gt;<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;XXXXXXXX&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, SYMLINK+=&quot;arduino_1&quot;<br /> &lt;/nowiki&gt;&lt;/pre&gt;<br /> <br /> Change 'ATTRS{serial}==&quot;XXXXXXXX&quot;' to the serial on your device and force udev to load the new rule:<br /> <br /> udevadm control --reload-rules<br /> <br /> At this point, whenever you plug in the device, the device should be renamed to {{ic|/dev/arduino_1}} or a link created. You can rename or link more by adding more lines to the rules file and extract the serial number for each device and of course name it what ever you like. The same process can be used for other USB-to-Serial devices as well.<br /> <br /> ==Communication==<br /> <br /> To communicate with the device, you can use any of the following, to name a few:<br /> <br /> * {{ic|minicom}}<br /> minicom -b 115200 -8 -D /dev/arduino_1<br /> * {{ic|screen}}<br /> screen /dev/arduino_1 115200 8N1<br /> * {{ic|picocom}}<br /> picocom -b 115200 -p n -d 8 /dev/arduino_1<br /> * {{ic|putty}} - gui utility<br /> putty -serial /dev/arduino_1 -sercfg 115200,8,n,1,X<br /> * {{ic|plink}} - cli utility<br /> plink -serial /dev/arduino_1 -sercfg 115200,8,n,1,X</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Communications_-_SQLite Arduino Communications - SQLite 2015-04-22T15:10:50Z <p>Jvaughters: /* Data Slam Method */</p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> ==Overview==<br /> When writing code these days it is silly to not use a database to manage your data. It significantly cuts the amount of code needed to manage data. So why not just collect the Arduino output directly into a database and allow any software access to the database? <br /> <br /> This article shows you how to use a database to collect Arduino data directly from the serial port and place the data into an SQLite database using scripts. This article will provide examples for Linux and Windows.<br /> <br /> ==Technical Assumptions==<br /> <br /> * Users are familiar with programming the Arduino<br /> * Users know how to install and use SQLite (Most Linux computers have it by default)<br /> * It would be helpful to be knowledgeable about bash scripting<br /> <br /> ==Linux==<br /> Ok, well I am starting with Linux. Why? Well.... Linux is smooth! It treats all devices like files. Meaning once you know how to open a file in Linux, you basically know how to access any device. How great is that? Someone was thinking when they created that idea. The operating system drivers are made to make this possible. So in the case of a serial port all you have to do is an ''stty'' command to set the transmission rates and the communications parameters and BOOM... like magic a serial port can be treated like a file. This allows you to use common commands that are used on files on a serial port. For instance, you can use ''echo'' to send commands to the serial device, just as you would use it to send to a file. <br /> <br /> ===Data Slam Method===<br /> The goal here is to push out all the data of the Arduino as fast as we can and load it into the database. To do that use this Arduino Sketch:<br /> <br /> &lt;source lang=&quot;c&quot;&gt;<br /> /*<br /> * Data Slam v.01<br /> * by &lt;http://www.combustory.com&gt; John Vaughters<br /> */<br /> #include &quot;Wire.h&quot;<br /> // Global Variables<br /> unsigned int diff_mil_time;<br /> long last_mil_time;<br /> <br /> void setup() {<br /> Wire.begin();<br /> Serial.begin(115200);<br /> }<br /> <br /> void loop() {<br /> // diff_mil_time = (int) (millis() - last_mil_time);<br /> diff_mil_time = (unsigned int) (millis() - 1 +1);<br /> // last_mil_time = millis();<br /> Serial.print(diff_mil_time);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(2),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(3),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(4),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(5),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(6),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(7),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(8),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(9),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(10),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(11),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(digitalRead(12),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(analogRead(0),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(analogRead(1),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(analogRead(2),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(analogRead(3),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(analogRead(4),DEC);<br /> Serial.print(&quot;,&quot;);<br /> Serial.print(analogRead(5),DEC);<br /> Serial.println(&quot;&quot;);<br /> delay(45); //poll time setting can be changed<br /> }<br /> //*****************************************************The End***********************<br /> <br /> &lt;/source&gt;<br /> <br /> Once the Arduino sketch is loaded, then use the code below to create a BASH script with a file named &quot;read_arduino.sh&quot;. <br /> <br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #!/bin/bash<br /> # Data Slam Script v0.1<br /> # User define Function (UDF)<br /> LogLine(){<br /> echo -E &quot;`date +%s`,${line}&quot;<br /> sqlite3 arduino.db3 &quot;insert into arduino_data(time_stamp,millis,di2,di3,di4,di5,di6,di7,di8,di9,di10,di11,di12,ai1,ai2,ai3,ai4,ai5,ai6) values (`date +%s`,${line})&quot;<br /> } <br /> ### Main script stars here ###<br /> # Store file name<br /> FILE=&quot;&quot;<br /> <br /> # Make sure we get file name as command line argument<br /> # Else read it from standard input device<br /> stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> if [ &quot;$1&quot; == &quot;&quot; ]; then<br /> FILE=&quot;/dev/ttyUSB0&quot;<br /> else<br /> FILE=&quot;$1&quot;<br /> # make sure file (serial device) exist and is readable<br /> if [ ! -f $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> fi<br /> fi<br /> # Create Database if it does not exist<br /> <br /> if [ ! -f &quot;arduino.db3&quot; ]; then<br /> echo &quot;Creating database&quot;<br /> sqlite3 arduino.db3 &quot;CREATE TABLE arduino_data (time_stamp integer ,millis integer, di2 integer, di3 integer, di4 integer, di5 integer, di6 integer,<br /> di7 integer, di8 integer, di9 integer, di10 integer, di11 integer, di12 integer,<br /> ai1 integer, ai2 integer, ai3 integer, ai4 integer, ai5 integer, ai6 integer);&quot;<br /> fi<br /> exec 3&lt;&amp;0<br /> exec 0&lt;&quot;$FILE&quot;<br /> while true<br /> do<br /> <br /> # use $line variable to process line in processLine() function<br /> while read -r line<br /> do<br /> LogLine $line<br /> done<br /> usleep 50000 # This delay can be changed to match the delay of the Arduino<br /> done<br /> exec 0&lt;&amp;3<br /> exit 0<br /> &lt;/source&gt;<br /> <br /> Now make the file executable with the following command.<br /> <br /> chmod 755 read_arduino.sh<br /> <br /> Run the script with the following command<br /> <br /> ./read_arduino.sh<br /> <br /> At this point, if you are lucky, you are seeing data separated by commas spit out on your screen. This is the data being loaded into SQLite. To exit the script, hit ctrl-c (^c). <br /> <br /> '''Sample Script Output Data:'''<br /> <br /> &lt;pre&gt;<br /> 1327361512,1752,0,0,0,0,0,0,0,0,0,0,0,506,499,491,483,1023,1023<br /> 1327361512,1802,0,0,0,0,0,0,0,0,0,0,0,506,500,491,482,1023,1023<br /> 1327361512,1852,0,0,0,0,0,0,0,0,0,0,0,507,500,490,482,1023,1023<br /> 1327361512,1901,0,0,0,0,0,0,0,0,0,0,0,507,501,491,482,1023,1023<br /> 1327361513,1951,0,0,0,0,0,0,0,0,0,0,0,507,499,491,482,1023,1023<br /> 1327361513,2001,0,0,0,0,0,0,0,0,0,0,0,507,501,491,483,1023,1023<br /> 1327361513,2052,0,0,0,0,0,0,0,0,0,0,0,506,499,492,484,1023,1023<br /> 1327361513,2102,0,0,0,0,0,0,0,0,0,0,0,506,500,492,484,1023,1023<br /> 1327361513,2152,0,0,0,0,0,0,0,0,0,0,0,507,500,491,483,1023,1023<br /> 1327361513,2202,0,0,0,0,0,0,0,0,0,0,0,507,500,492,484,1023,1022<br /> &lt;/pre&gt;<br /> <br /> Now check if the SQLite database was created with the command.<br /> <br /> ls -la arduino_data.db3<br /> <br /> If you see the file, then run this command to see your data<br /> <br /> sqlite3 arduino.db3 'select * from arduino_data'<br /> <br /> Sample SQLite Output Data:<br /> <br /> &lt;pre&gt;<br /> 1327361513|2001|0|0|0|0|0|0|0|0|0|0|0|507|501|491|483|1023|1023<br /> 1327361513|2052|0|0|0|0|0|0|0|0|0|0|0|506|499|492|484|1023|1023<br /> 1327361513|2102|0|0|0|0|0|0|0|0|0|0|0|506|500|492|484|1023|1023<br /> 1327361513|2152|0|0|0|0|0|0|0|0|0|0|0|507|500|491|483|1023|1023<br /> 1327361513|2202|0|0|0|0|0|0|0|0|0|0|0|507|500|492|484|1023|1022<br /> &lt;/pre&gt;<br /> <br /> ===Troubleshooting===<br /> <br /> Sections not Completed<br /> <br /> So you weren't lucky and you received errors somewhere in this process. Let's verify a few things first.<br /> <br /> ==Windows==<br /> If you jumped straight to this section, I recommend that you read the Linux section and understand the overall concept. The problem with Windows is that the communication with serial ports is not as easy. The only way to communicate through software that you write is to have a license to the software objects that provide communication to serial ports. Well.... we cannot have that, so we will have to resort to an open source solution.<br /> <br /> TeraTerm Pro is a terminal emulator that can communicate with serial ports as well as telnet and ssh. It also has a very rich macro language for automating terminal sessions that we will use to talk with the Arduino. There are many great applications for this software, like using it to control or configure devices that are accessed via ssh or telnet. So if you are new to TeraTerm Pro, it should significantly improve your toolbox of software utilities. <br /> <br /> ===Data Slam Method===<br /> The goal here is to push out all the data of the Arduino as fast as we can and load it into the database. To do that use the same Arduino Sketch found in the Linux section of this article.<br /> <br /> Create a text file named ''read_arduino.ttl'' with the code below. Place it in the ''c:\Program Files\teraterm'' directory. If this directory does not exist, then you need to install TeraTerm.<br /> <br /> &lt;source lang=&quot;TeraTerm&quot;&gt;<br /> ;Read Arduino Macro v.01<br /> ;by &lt;http://combustory.com&gt; John Vaughters<br /> filesearch 'arduino.db3' ;Check if database exists and create if it doesn't <br /> if result=0 then<br /> fileopen fhandle 'create_db.bat' 0 ;The create table string was too long for script strings so I made a bat file and exec the bat file<br /> filewrite fhandle 'sqlite3 arduino.db3 &quot;CREATE TABLE arduino_data (time_stamp char, millis integer, di2 integer, di3 integer, di4 integer,'<br /> filewrite fhandle ' di5 integer, di6 integer, di7 integer, di8 integer, di9 integer, di10 integer, di11 integer, di12 integer, ai1 integer,'<br /> filewrite fhandle 'ai2 integer, ai3 integer, ai4 integer, ai5 integer, ai6 integer)&quot;'<br /> fileclose fhandle<br /> exec 'create_db.bat' &quot;HIDE&quot; 1<br /> filedelete 'create_db.bat'<br /> endif<br /> ;connect '/V /C=18' ;Com Port 18 - Start with hidden terminal<br /> connect '/C=18' ;Com Port 18 - Start with visible terminal<br /> setbaud 115200<br /> setsync 1<br /> while 1 ; endless loop to read Arduino<br /> ; receive one line<br /> recvln<br /> ; build SQLite command string<br /> command = 'sqlite3 arduino.db3 &quot;insert into arduino_data(time_stamp,millis,di2,di3,di4,di5,di6,di7,di8,di9,di10,di11,di12,ai1,ai2,ai3,ai4,ai5,ai6) values ('<br /> gettime time_status &quot;%Y%m%d%H%M%S,&quot;<br /> strconcat command time_status<br /> strconcat command inputstr ;inputstr is the arduino output from recvln <br /> strconcat command ');&quot;'<br /> ; write it to SQLite<br /> exec command &quot;HIDE&quot;<br /> endwhile<br /> &lt;/source&gt; <br /> <br /> Change this line to match your com port. My com port was 18, so just change the 18 to match your number. (Hint: Use Arduino programming environment to find the Arduino com port ie. Menu Item: Tools&gt;Serial Port)<br /> <br /> connect '/C=18'<br /> <br /> Make sure you have the ''sqlite3.exe'' and ''sqlite.dll'' in the ''c:\Program Files\teraterm'' directory. These are the SQLite windows files needed for SQLite to work. It really is that simple with SQLite and Windows. You only need those two files. I normally have a path to those files, but they are small enough that I put them in the directory for applications that I create for others, to make sure the applications work.<br /> <br /> Use this command to run the Macro. (Create a batch file to reduce typing)<br /> <br /> &quot;C:\Program Files\teraterm\ttpmacro.exe&quot; read_arduino.ttl<br /> <br /> If you are lucky, you will see output coming across a TeraTerm console. To stop the data, just delete the console window and end the macro via the pop up boxes. Now check if you have a file named ''arduino.db3'' in the ''c:\Program Files\teraterm'' directory. If so run this command to see the data in SQLite. (Make sure you are in the ''c:\Program Files\teraterm'' directory when running this command.)<br /> <br /> sqlite3 arduino.db3 &quot;select * from arduino_data&quot; <br /> <br /> ===Troubleshooting===<br /> <br /> Sections not Completed<br /> <br /> So you weren't lucky and you received errors somewhere in this process. Let's verify a few things first.<br /> <br /> <br /> [[Category:Electronics]]</div> Jvaughters http://www.combustory.com/wiki/index.php/Deflated_Balls Deflated Balls 2015-01-23T16:28:09Z <p>Jvaughters: /* Ideal Gas Equation */</p> <hr /> <div>=Introduction=<br /> If you clicked on this link trying to gain information about your old sagging man-hood, be glad that this doesn't apply to you. The reason for this web page is to evaluate the Deflated Football from a scientific feasibility test on how a ball could become depressurized by Half Time even though New England met the specification at the NFL required time two hours before the game.<br /> <br /> =Ideal Gas Equation=<br /> PV = nRT<br /> <br /> * P = Pressure (Pa)<br /> * V = Volume (m^3)<br /> * n = Number of moles<br /> * T = Temperature (K)<br /> <br /> =State 1=<br /> ==Assumptions==<br /> * Balls were inside the locker room or building at the pressure inspection time<br /> * Balls are brand new<br /> * Balls met the minimum required pressure test two hours prior to the game<br /> ==Equation==<br /> (P1)(V1)= nR(T1)<br /> <br /> =State 2=<br /> ==Assumptions==<br /> * Balls were outside in the playing field all the way until half time<br /> * Balls were used in the game at various times throughout the first half<br /> * Balls were not tampered with in any way to change the pressure through air mass reduction<br /> ==Equation==<br /> (P2)(V2)= nR(T2)<br /> <br /> =Case 1=<br /> ==Assumptions==<br /> * Ball remains constant Volume (V1=V2)<br /> * nR is a constant for both states<br /> * T1 = 82 F = 301 K<br /> * T2 = 50 F = 283 K<br /> * P1 = 12.5 psi = 86207 Pa<br /> ==Equation==<br /> P2 = (P1)(T2/T1)<br /> <br /> Note: Solve two equations for nR and V1 and V2 cancel<br /> <br /> ==Result==<br /> P2 = (86207)(283/301) = 82143 Pa = 11.8 psi<br /> <br /> =Case 2=<br /> ==Assumptions==<br /> * Ball volume changes from wear and tear 5% increase in volume (V1/V2) = 0.95<br /> * Conditions from Case 1 exactly the same<br /> ==Equation==<br /> P2 = (P1)(T2/T1)(V1/V2)<br /> <br /> ==Result==<br /> P2 = (86207)(283/301)(0.95) = 76999 Pa = 11.2 psi<br /> <br /> =Summary=<br /> Case 1 is a viable situation, yet the pressure drop is minimal due to temperature alone. In case 2 we are very generous on the the volume expansion. It is doubtful that the volume changes very much on a new ball, if at all. However, even with the generous volume expansion, the pressure drop still is only 1.3 psi. <br /> <br /> The probability of a full 2 psi drop in pressure is doubtful, but cannot be completely ruled out as impossible. The part that we do not know is the exact measurements of the footballs before and after for each football and that is very important. If there was significant variation, you could have some evidence that a new football can change in volume if the lower pressure balls were also the balls used most. Probably a kicked ball being the most likely to change volume. The biggest public evidence is the fact that 11 of the 12 were low and that is a tough probability to ignore.<br /> <br /> =Final Judgement=<br /> The final conclusion is '''Plausible''' but '''Unlikely'''.<br /> <br /> =NFL Rules=<br /> The NFL rules matter here. If there is no temperature at time of measurement rule stated, then does the NFL really have a case against New England? I say no. A small fine at best is the worst punishment, and a rule change to prevent this exploit in the future.</div> Jvaughters http://www.combustory.com/wiki/index.php/Deflated_Balls Deflated Balls 2015-01-23T16:26:43Z <p>Jvaughters: /* Final Judgement */</p> <hr /> <div>=Introduction=<br /> If you clicked on this link trying to gain information about your old sagging man-hood, be glad that this doesn't apply to you. The reason for this web page is to evaluate the Deflated Football from a scientific feasibility test on how a ball could become depressurized by Half Time even though New England met the specification at the NFL required time two hours before the game.<br /> <br /> =Ideal Gas Equation=<br /> PV = nRT<br /> <br /> P = Pressure (Pa)<br /> V = Volume (m^3)<br /> n = Number of moles<br /> T = Temperature (K)<br /> <br /> =State 1=<br /> ==Assumptions==<br /> * Balls were inside the locker room or building at the pressure inspection time<br /> * Balls are brand new<br /> * Balls met the minimum required pressure test two hours prior to the game<br /> ==Equation==<br /> (P1)(V1)= nR(T1)<br /> <br /> =State 2=<br /> ==Assumptions==<br /> * Balls were outside in the playing field all the way until half time<br /> * Balls were used in the game at various times throughout the first half<br /> * Balls were not tampered with in any way to change the pressure through air mass reduction<br /> ==Equation==<br /> (P2)(V2)= nR(T2)<br /> <br /> =Case 1=<br /> ==Assumptions==<br /> * Ball remains constant Volume (V1=V2)<br /> * nR is a constant for both states<br /> * T1 = 82 F = 301 K<br /> * T2 = 50 F = 283 K<br /> * P1 = 12.5 psi = 86207 Pa<br /> ==Equation==<br /> P2 = (P1)(T2/T1)<br /> <br /> Note: Solve two equations for nR and V1 and V2 cancel<br /> <br /> ==Result==<br /> P2 = (86207)(283/301) = 82143 Pa = 11.8 psi<br /> <br /> =Case 2=<br /> ==Assumptions==<br /> * Ball volume changes from wear and tear 5% increase in volume (V1/V2) = 0.95<br /> * Conditions from Case 1 exactly the same<br /> ==Equation==<br /> P2 = (P1)(T2/T1)(V1/V2)<br /> <br /> ==Result==<br /> P2 = (86207)(283/301)(0.95) = 76999 Pa = 11.2 psi<br /> <br /> =Summary=<br /> Case 1 is a viable situation, yet the pressure drop is minimal due to temperature alone. In case 2 we are very generous on the the volume expansion. It is doubtful that the volume changes very much on a new ball, if at all. However, even with the generous volume expansion, the pressure drop still is only 1.3 psi. <br /> <br /> The probability of a full 2 psi drop in pressure is doubtful, but cannot be completely ruled out as impossible. The part that we do not know is the exact measurements of the footballs before and after for each football and that is very important. If there was significant variation, you could have some evidence that a new football can change in volume if the lower pressure balls were also the balls used most. Probably a kicked ball being the most likely to change volume. The biggest public evidence is the fact that 11 of the 12 were low and that is a tough probability to ignore.<br /> <br /> =Final Judgement=<br /> The final conclusion is '''Plausible''' but '''Unlikely'''.<br /> <br /> =NFL Rules=<br /> The NFL rules matter here. If there is no temperature at time of measurement rule stated, then does the NFL really have a case against New England? I say no. A small fine at best is the worst punishment, and a rule change to prevent this exploit in the future.</div> Jvaughters http://www.combustory.com/wiki/index.php/Deflated_Balls Deflated Balls 2015-01-23T16:25:19Z <p>Jvaughters: /* Summary */</p> <hr /> <div>=Introduction=<br /> If you clicked on this link trying to gain information about your old sagging man-hood, be glad that this doesn't apply to you. The reason for this web page is to evaluate the Deflated Football from a scientific feasibility test on how a ball could become depressurized by Half Time even though New England met the specification at the NFL required time two hours before the game.<br /> <br /> =Ideal Gas Equation=<br /> PV = nRT<br /> <br /> P = Pressure (Pa)<br /> V = Volume (m^3)<br /> n = Number of moles<br /> T = Temperature (K)<br /> <br /> =State 1=<br /> ==Assumptions==<br /> * Balls were inside the locker room or building at the pressure inspection time<br /> * Balls are brand new<br /> * Balls met the minimum required pressure test two hours prior to the game<br /> ==Equation==<br /> (P1)(V1)= nR(T1)<br /> <br /> =State 2=<br /> ==Assumptions==<br /> * Balls were outside in the playing field all the way until half time<br /> * Balls were used in the game at various times throughout the first half<br /> * Balls were not tampered with in any way to change the pressure through air mass reduction<br /> ==Equation==<br /> (P2)(V2)= nR(T2)<br /> <br /> =Case 1=<br /> ==Assumptions==<br /> * Ball remains constant Volume (V1=V2)<br /> * nR is a constant for both states<br /> * T1 = 82 F = 301 K<br /> * T2 = 50 F = 283 K<br /> * P1 = 12.5 psi = 86207 Pa<br /> ==Equation==<br /> P2 = (P1)(T2/T1)<br /> <br /> Note: Solve two equations for nR and V1 and V2 cancel<br /> <br /> ==Result==<br /> P2 = (86207)(283/301) = 82143 Pa = 11.8 psi<br /> <br /> =Case 2=<br /> ==Assumptions==<br /> * Ball volume changes from wear and tear 5% increase in volume (V1/V2) = 0.95<br /> * Conditions from Case 1 exactly the same<br /> ==Equation==<br /> P2 = (P1)(T2/T1)(V1/V2)<br /> <br /> ==Result==<br /> P2 = (86207)(283/301)(0.95) = 76999 Pa = 11.2 psi<br /> <br /> =Summary=<br /> Case 1 is a viable situation, yet the pressure drop is minimal due to temperature alone. In case 2 we are very generous on the the volume expansion. It is doubtful that the volume changes very much on a new ball, if at all. However, even with the generous volume expansion, the pressure drop still is only 1.3 psi. <br /> <br /> The probability of a full 2 psi drop in pressure is doubtful, but cannot be completely ruled out as impossible. The part that we do not know is the exact measurements of the footballs before and after for each football and that is very important. If there was significant variation, you could have some evidence that a new football can change in volume if the lower pressure balls were also the balls used most. Probably a kicked ball being the most likely to change volume. The biggest public evidence is the fact that 11 of the 12 were low and that is a tough probability to ignore.<br /> <br /> =Final Judgement=<br /> The final Conclusion is Plausible but Unlikely.<br /> <br /> =NFL Rules=<br /> The NFL rules matter here. If there is no temperature at time of measurement rule stated, then does the NFL really have a case against New England? I say no. A small fine at best is the worst punishment, and a rule change to prevent this exploit in the future.</div> Jvaughters http://www.combustory.com/wiki/index.php/Deflated_Balls Deflated Balls 2015-01-23T16:23:10Z <p>Jvaughters: /* Introduction */</p> <hr /> <div>=Introduction=<br /> If you clicked on this link trying to gain information about your old sagging man-hood, be glad that this doesn't apply to you. The reason for this web page is to evaluate the Deflated Football from a scientific feasibility test on how a ball could become depressurized by Half Time even though New England met the specification at the NFL required time two hours before the game.<br /> <br /> =Ideal Gas Equation=<br /> PV = nRT<br /> <br /> P = Pressure (Pa)<br /> V = Volume (m^3)<br /> n = Number of moles<br /> T = Temperature (K)<br /> <br /> =State 1=<br /> ==Assumptions==<br /> * Balls were inside the locker room or building at the pressure inspection time<br /> * Balls are brand new<br /> * Balls met the minimum required pressure test two hours prior to the game<br /> ==Equation==<br /> (P1)(V1)= nR(T1)<br /> <br /> =State 2=<br /> ==Assumptions==<br /> * Balls were outside in the playing field all the way until half time<br /> * Balls were used in the game at various times throughout the first half<br /> * Balls were not tampered with in any way to change the pressure through air mass reduction<br /> ==Equation==<br /> (P2)(V2)= nR(T2)<br /> <br /> =Case 1=<br /> ==Assumptions==<br /> * Ball remains constant Volume (V1=V2)<br /> * nR is a constant for both states<br /> * T1 = 82 F = 301 K<br /> * T2 = 50 F = 283 K<br /> * P1 = 12.5 psi = 86207 Pa<br /> ==Equation==<br /> P2 = (P1)(T2/T1)<br /> <br /> Note: Solve two equations for nR and V1 and V2 cancel<br /> <br /> ==Result==<br /> P2 = (86207)(283/301) = 82143 Pa = 11.8 psi<br /> <br /> =Case 2=<br /> ==Assumptions==<br /> * Ball volume changes from wear and tear 5% increase in volume (V1/V2) = 0.95<br /> * Conditions from Case 1 exactly the same<br /> ==Equation==<br /> P2 = (P1)(T2/T1)(V1/V2)<br /> <br /> ==Result==<br /> P2 = (86207)(283/301)(0.95) = 76999 Pa = 11.2 psi<br /> <br /> =Summary=<br /> Case 1 is a viable situation, yet the pressure drop is minimal due to temperature alone. In case 2 we are very generous on the the volume expansion. It is doubtful that the volume changes very much on a new ball, if at all. However, even with the generous volume expansion, the pressure drop still is only 1.3 psi. <br /> <br /> The probability of a full 2 psi drop in pressure is doubtful, but cannot be completely ruled out as impossible. The part that we do not know is the exact measurements of the footballs before and after for each football and that is very important. If there was significant variation, you could have some evidence that a new football can change in volume if the lower pressure balls were also the balls used most. Probably a kicked ball being the most likely to change volume. The biggest public evidence is the fact that 11 of the 12 were low and that is a tough probability to ignore.<br /> <br /> The end result is Plausible but Unlikely.<br /> <br /> =NFL Rules=<br /> The NFL rules matter here. If there is no temperature at time of measurement rule stated, then does the NFL really have a case against New England? I say no. A small fine at best is the worst punishment, and a rule change to prevent this exploit in the future.</div> Jvaughters http://www.combustory.com/wiki/index.php/Deflated_Balls Deflated Balls 2015-01-23T16:22:05Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> If you clicked on this link trying to gain information about your old sagging man-hood, be glad that this doesn't apply to you. The reason for this web page is to evaluate the Deflated Football from a scientific feasibility test on how a ball could become depressurized by Half Time even though they met the specification at the NFL required time two hours before the game.<br /> <br /> =Ideal Gas Equation=<br /> PV = nRT<br /> <br /> P = Pressure (Pa)<br /> V = Volume (m^3)<br /> n = Number of moles<br /> T = Temperature (K)<br /> <br /> =State 1=<br /> ==Assumptions==<br /> * Balls were inside the locker room or building at the pressure inspection time<br /> * Balls are brand new<br /> * Balls met the minimum required pressure test two hours prior to the game<br /> ==Equation==<br /> (P1)(V1)= nR(T1)<br /> <br /> =State 2=<br /> ==Assumptions==<br /> * Balls were outside in the playing field all the way until half time<br /> * Balls were used in the game at various times throughout the first half<br /> * Balls were not tampered with in any way to change the pressure through air mass reduction<br /> ==Equation==<br /> (P2)(V2)= nR(T2)<br /> <br /> =Case 1=<br /> ==Assumptions==<br /> * Ball remains constant Volume (V1=V2)<br /> * nR is a constant for both states<br /> * T1 = 82 F = 301 K<br /> * T2 = 50 F = 283 K<br /> * P1 = 12.5 psi = 86207 Pa<br /> ==Equation==<br /> P2 = (P1)(T2/T1)<br /> <br /> Note: Solve two equations for nR and V1 and V2 cancel<br /> <br /> ==Result==<br /> P2 = (86207)(283/301) = 82143 Pa = 11.8 psi<br /> <br /> =Case 2=<br /> ==Assumptions==<br /> * Ball volume changes from wear and tear 5% increase in volume (V1/V2) = 0.95<br /> * Conditions from Case 1 exactly the same<br /> ==Equation==<br /> P2 = (P1)(T2/T1)(V1/V2)<br /> <br /> ==Result==<br /> P2 = (86207)(283/301)(0.95) = 76999 Pa = 11.2 psi<br /> <br /> =Summary=<br /> Case 1 is a viable situation, yet the pressure drop is minimal due to temperature alone. In case 2 we are very generous on the the volume expansion. It is doubtful that the volume changes very much on a new ball, if at all. However, even with the generous volume expansion, the pressure drop still is only 1.3 psi. <br /> <br /> The probability of a full 2 psi drop in pressure is doubtful, but cannot be completely ruled out as impossible. The part that we do not know is the exact measurements of the footballs before and after for each football and that is very important. If there was significant variation, you could have some evidence that a new football can change in volume if the lower pressure balls were also the balls used most. Probably a kicked ball being the most likely to change volume. The biggest public evidence is the fact that 11 of the 12 were low and that is a tough probability to ignore.<br /> <br /> The end result is Plausible but Unlikely.<br /> <br /> =NFL Rules=<br /> The NFL rules matter here. If there is no temperature at time of measurement rule stated, then does the NFL really have a case against New England? I say no. A small fine at best is the worst punishment, and a rule change to prevent this exploit in the future.</div> Jvaughters http://www.combustory.com/wiki/index.php/Deflated_Balls Deflated Balls 2015-01-23T00:51:35Z <p>Jvaughters: Created page with &quot;&lt;math&gt; a^2&lt;/math&gt;&quot;</p> <hr /> <div>&lt;math&gt; a^2&lt;/math&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Down_There Down There 2013-04-29T21:55:03Z <p>Jvaughters: Created page with &quot;By John Vaughters &lt;pre&gt; Well I'll tell you this story, One well burned in mind Not even Alziemers could leave this behind The story is true and all that is stated A form of small...&quot;</p> <hr /> <div>By John Vaughters<br /> &lt;pre&gt;<br /> Well I'll tell you this story, One well burned in mind<br /> Not even Alziemers could leave this behind<br /> The story is true and all that is stated<br /> A form of small torture one very ill fated<br /> <br /> On a typical day of a typical morn<br /> My Mother, your Grandmother was on her chore<br /> Fat back and Bacon was the 70's way<br /> And so were heart attacks back in them days<br /> <br /> With bacon complete and stacked oh so neat<br /> it was time for the eggs and in they went<br /> with a bath of bacon grease ready and hot<br /> no need for turning, just a splash on the top<br /> <br /> One little mistake from a busy distraction<br /> One splash too many for this grave infraction<br /> Over the top<br /> Out of the pan<br /> Onto the burner <br /> And then came fire<br /> With one final crash<br /> <br /> There arose such a flame it was out of control<br /> rising to the ceiling with it's dark black soul<br /> <br /> Fire alarm You say? I think NOT!<br /> Hysterical screaming is all we GOT!<br /> We fled from our bed and into the hall<br /> We stopped in our tracks to see such a sight<br /> we could not move we had such fright<br /> <br /> BILL BILL BILL the wailing continued<br /> Even over the shower the sound went in you<br /> In a rush to see what the screech was about<br /> He moved quick, even nearly fell out<br /> <br /> To the kitchen he went without even thinking<br /> All he knew was his dansel was screaming<br /> He arrived at the kitchen, grease on a tear<br /> Three kids brightly staring, hey what's that there?<br /> <br /> Wiggly jiggly it it moved all around <br /> Flippity Flop it made such a sound<br /> Back in the 70's unlike today<br /> it wasn't polite but just to say, &quot;Hey something's going on down there&quot;<br /> <br /> Was it the fire or his eggs that caused his reaction<br /> Only he knows what put him in action<br /> He reached for a glass and was filling the water<br /> When mother struck quick and saw a GREAT matter<br /> Oh my, this will cause such a splatter<br /> <br /> Was it the fire or down there that caused her reaction<br /> Only she knows what put her in action<br /> Selfish or not she pulled from the cupboard<br /> Some white powdered soda that created a smother<br /> Out went the fire with Bill standing ready<br /> Fresh water in glass and all watching steady<br /> <br /> After the fire, all was well<br /> except three kids whose jaws had fell<br /> <br /> BILL! Jeanne shout out, You're Naked!!! <br /> Oh what truth she just spout<br /> <br /> With a quick little Shutter <br /> He moved his bare ass<br /> He moved it real fast<br /> He shot like a bull and left all a flutter<br /> Flippity Flop, Flippity Flop, as the sound turned down<br /> <br /> Jeanne, My mother, your grandmother turned with a grin<br /> she stated quite nicely and very politely<br /> Go get dressed and I'll get your breakfast.<br /> Wheaties is was with Bruce Jenner our Champion.<br /> <br /> With Man Hood in tact, we all must exclaim<br /> that my mother, your grandmother saved my father, your grandfather<br /> from a lifetime of shame by smothering that fire and protecting Down There.<br /> <br /> &lt;/pre&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev Arduino Communications Device Naming with udev 2013-03-13T12:36:57Z <p>Jvaughters: </p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> __NOTOC__<br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> {{Article summary start}}<br /> {{Article summary text|This article covers the configuration of udev for Arduino Communication.}}<br /> {{Article summary end}}<br /> <br /> ==Summary==<br /> If you use more than one Arduino with USB or have other USB-to-Serial devices, then you may find it convenient to make the device have the same name every time you reboot or connect the Arduino. The technique here is shown for an FTDI device, but the same process can be used for just about any USB-to-Serial device that the system recognizes.<br /> <br /> ==Assumptions==<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> <br /> ==Installation==<br /> <br /> {{Note|All scripts will assume that there is a '{{ic|/dev/arduino_1}}'.}}<br /> <br /> The drivers for the FTDI chip is included in the kernel, so it should be detected as soon as it's plugged in, and assigned to device {{ic|/dev/ttyUSB[0-9]}}.<br /> To check where it got assigned, run:<br /> <br /> dmesg | grep FTDI<br /> <br /> The output will contain a line that looks something like this:<br /> <br /> usb 1-4.4: FTDI USB Serial Device converter now attached to ttyUSB0<br /> <br /> ===udev===<br /> <br /> It can be annoying to have to look up what {{ic|/dev/ttyUSB[0-9]}} the device gets assigned, so it's a good idea to add a simple udev rule that creates and renames the device when it is plugged in.<br /> <br /> First of all, you will need to find out the serial number of FTDI chip on the Arduino. This can be achieved by running the following, assuming your device is plugged in and was assigned to {{ic|/dev/ttyUSB0}}:<br /> <br /> udevadm info --attribute-walk -n /dev/ttyUSB0<br /> <br /> Now add/create the following file:<br /> <br /> {{hc|/etc/udev/rules.d/98-arduino.rules|2=<br /> &lt;nowiki&gt;<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;XXXXXXXX&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> &lt;/nowiki&gt;}}<br /> <br /> Change 'ATTRS{serial}==&quot;XXXXXXXX&quot;' to the serial on your device and force udev to load the new rule:<br /> <br /> udevadm control --reload-rules<br /> <br /> At this point, whenever you plug in the device, the device should be renamed to {{ic|/dev/arduino_1}}. You can rename more by adding more lines to the rules file and extract the serial number for each device and of course name it what ever you like. The same process can be used for other USB-to-Serial devices as well. <br /> <br /> ==Communication==<br /> <br /> To communicate with the device, you can use any of the following, to name a few:<br /> <br /> * {{ic|minicom}}<br /> minicom -b 115200 -8 -D /dev/arduino_1<br /> * {{ic|screen}}<br /> screen /dev/arduino_1 115200 8N1<br /> * {{ic|picocom}}<br /> picocom -b 115200 -p n -d 8 /dev/arduino_1<br /> * {{ic|putty}} - gui utility<br /> putty -serial /dev/arduino_1 -sercfg 115200,8,n,1,X<br /> * {{ic|plink}} - cli utility<br /> plink -serial /dev/arduino_1 -sercfg 115200,8,n,1,X</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-08T21:59:11Z <p>Jvaughters: </p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> <br /> <br /> =Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up and the computer is useful even in this state, but I believe you will find it beneficial to make some more changes. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> ===Best Practices===<br /> If you have created a bootable PXE system, then you are off to a great start. Since the configuration part can take some time, you may want to save the file periodically. That way if you make a mistake, you do not loose all your effort. Fortunately this is a breeze. You only need to copy one file. In a jam, you can extract this file and create known good root file system.<br /> <br /> * Create backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz.bak<br /> * restore the backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/core_root<br /> rm -rf /tftpboot/tc_pxe/tc_pxe_dev/core_root/*<br /> zcat ../ard-core.gz.bak | sudo cpio -i -H newc -d<br /> <br /> ===Create New Root File System===<br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> If you plan on using this server for more than just an [[Arduino Server]] I recommend you configure ssh, which I included in the additional packages. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> * Log into your TinyCore computer via ssh (Change ip's to match your network, accept ssh key and enter password), then copy key files over via scp<br /> ssh tc@192.168.1.150<br /> sudo scp /etc/dropbear/dropbear_dss_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/<br /> sudo scp /etc/dropbear/dropbear_rsa_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/ <br /> exit<br /> * Update the root file system per instructions above. <br /> * Next time you reboot, you should be able to access ssh without accepting a key<br /> <br /> ==Change the tc_pxe directory name==<br /> You may want to use your own directory names and if you want to have multiple computers using different images, then you will want to consider changing the tc_pxe directory name.<br /> <br /> * Change directory to ard_srv_1 from tc_pxe<br /> sed -i 's/tc_pxe/ard_srv_1/g' /tftpboot/tc_pxe/cde/onboot_x.lst<br /> sed -i 's/tc_pxe/ard_srv_1/g' /tftpboot/tc_pxe/pxelinux.cfg/default<br /> cd /tftpboot<br /> mv tc_pxe ard_srv_1<br /> * Point your PXE set up to the new directory and you are good to go.<br /> <br /> ==Other Configuration Ideas==<br /> * Use multiple servers with different image directories. Study how to boot PXE by MAC address.<br /> * Add packages to the PXE server. <br /> <br /> =Troubleshooting=<br /> <br /> <br /> ==Replace PXE TinyCore System==<br /> The best part of using TinyCore and this script is that if for some reason you messed up, you just start from scratch and it only takes a few minutes to run the script again as long as you do not delete the tc_downloads directory. It is even more useful if you had a running system from the start, then messed it up, then all you have to do is delete the /tftpboot/tc_pxe directory and then copy it from the ~/my_tinycore_dir directory.<br /> * Remove PXE set up and replace it with the default system created by script<br /> rm -rf /tftpboot/tc_pxe<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * More drastic measure to remove the default system and re-run script<br /> rm -rf ~/my_tinycore_dir/tc_pxe<br /> cd ~/my_tinycore_dir<br /> ./tc_pxe_script<br /> <br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Communications_Using_the_netcat(nc)_Utility Arduino Communications Using the netcat(nc) Utility 2012-11-08T20:14:13Z <p>Jvaughters: /* Linux */</p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> &lt;!--------------------------------Featured picture------------------------------<br /> {| id=&quot;mp-tfp&quot; style=&quot;margin:4px 0px 0px 0px; width:30%; background:none;&quot;<br /> |class=&quot;MainPageBG&quot; style=&quot;width:30%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&quot;|<br /> {| cellpadding=&quot;2&quot; cellspacing=&quot;5&quot; style=&quot;vertical-align:top; background:#faf5ff; color:#000; width:30%&quot;<br /> ! &lt;h3 id=&quot;mp-tfp-h2&quot; style=&quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:top; color:#000; padding:0.2em 0.4em&quot;&gt;Featured picture&lt;/h3&gt;<br /> |-<br /> |style=&quot;color:#000;&quot;| {{Featured Picture}}<br /> |}<br /> |}&lt;!--<br /> <br /> <br /> <br /> &lt;---------Interwiki strapline----------&gt;<br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> =Overview=<br /> Why reinvent the wheel. I have seen very complicated methods for communicating with the Arduino, Including some I have made on my own. What I have recently found out is that the easiest way to communicate to the Arduino is using the existing tool ''netcat''. It is soooooo simple and super powerful. You can send the output to a Network port and access the communications from literally any place in the world. <br /> <br /> =nc Versions=<br /> One thing that you have to realize is that there are more versions of netcat than there are versions of linux. Ok maybe that is a stretch, but it seems that every system that I use has a different version with different options or worse same option that acts differently. This is generally not an issue if you use the main versions of linux as they have come to use the same version. However, if you are using embedded linux with busybox, then make sure you look at the help to get the options. In general I recommend always looking at the help of nc(netcat) just to make sure, because I am constantly getting confused on which options to use on this command. <br /> <br /> There is also some windows versions that have with or without the -e option that is considered a gaping security hole, which is really quite over blown considering the other utilites that can do the same thing. But the claim on the securlty issue is quite ridiculas considering that you can still accomplish the same task using fifo's on linux. Windows is not as easy considering that you do not have the ability to create a fifo so easily from the command line. If you plan on using Windows, make sure you get the version with the -e aka - Gaping Security Hole.<br /> <br /> =Assumptions=<br /> * You have basic knowledge of command line usage <br /> * You know how to load a program to the Arduino<br /> <br /> =Linux=<br /> Here is the one line linux command that will send the serial terminal /dev/ttyUSB0 to a network TCP port:<br /> mkfifo arduino_fifo; nc -lk 2111 &lt;arduino_fifo | plink -serial /dev/ttyUSB0 -sercfg 115200,8,n,1,n &gt;arduino_fifo &amp;<br /> Before you start asking, plink is a command that is downloaded with the putty pacakge. Since I use windows and linux quite often, I decided to stick with putty as a multi-use package. It is easy to download and you can get it from any major linux distribution with the package manager that meets your linux distribution. You could just as easily replace putty with minicom or screen. I will leave it to the user to figure out which serial communication software to use.<br /> <br /> To explain the basis of this command we are redirecting inputs and outputs to get the information to the TCP port by looping back on a fifo (named pipe). So after you run this command you will able to connect to the port and communicate back and forth with the arduino. From another computer on your network, here is how you would connect to the port:<br /> <br /> nc 192.168.30.208 2111<br /> <br /> You would put the ip of the computer you have the Arduino connected to and port 2111 is the port we used on the nc command to send the data through that port. When you press enter on that command you will have direct access to that arduino and it's serial port through the network. Now you can access that port from wherever you are on the internet if you have access your network. I encourage you to use VPN's or ssh to securly access this port and do not just put it out on the web.<br /> <br /> =Mini2440 or Embedded Systems=<br /> Embedded systems like the Mini2440, use Busy Box as a small utility package that includes a version of nc that makes communications to Arduino a breeze. All you have to do is go to a terminal and use these two commands after you plug in the Arduino.<br /> <br /> stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> nc -f /dev/ttyUSB0<br /> <br /> You should now have a terminal session that is communicating with the Arduino. Of course you should have a program that responds to serial communication on the Arduino, or nothing will be happening. How this works is the ''nc'' command has redirected the input and output streams of the /dev/ttyUSB0, which is the Arduino terminal and the ''stty'' command sets the serial communication parameters. To exit out of the program, just use ''^C (ctrl-c)''<br /> <br /> <br /> Now we expand on this idea and we send the Arduino serial port to a network port with this command. <br /> <br /> nc -ll -p 2111 -e nc -f /dev/ttyUSB0<br /> <br /> This is where it gets interesting. Now you can access your Arduino from anywhere on the planet, or space if you still have a good satellite connection `,~) Use this command from any other computer that has ''netcat''.<br /> <br /> nc 192.168.30.206 2111<br /> <br /> Use the ip of your Mini2440 of course.</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Communications_Using_the_netcat(nc)_Utility Arduino Communications Using the netcat(nc) Utility 2012-11-08T20:11:37Z <p>Jvaughters: </p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> &lt;!--------------------------------Featured picture------------------------------<br /> {| id=&quot;mp-tfp&quot; style=&quot;margin:4px 0px 0px 0px; width:30%; background:none;&quot;<br /> |class=&quot;MainPageBG&quot; style=&quot;width:30%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&quot;|<br /> {| cellpadding=&quot;2&quot; cellspacing=&quot;5&quot; style=&quot;vertical-align:top; background:#faf5ff; color:#000; width:30%&quot;<br /> ! &lt;h3 id=&quot;mp-tfp-h2&quot; style=&quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:top; color:#000; padding:0.2em 0.4em&quot;&gt;Featured picture&lt;/h3&gt;<br /> |-<br /> |style=&quot;color:#000;&quot;| {{Featured Picture}}<br /> |}<br /> |}&lt;!--<br /> <br /> <br /> <br /> &lt;---------Interwiki strapline----------&gt;<br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> =Overview=<br /> Why reinvent the wheel. I have seen very complicated methods for communicating with the Arduino, Including some I have made on my own. What I have recently found out is that the easiest way to communicate to the Arduino is using the existing tool ''netcat''. It is soooooo simple and super powerful. You can send the output to a Network port and access the communications from literally any place in the world. <br /> <br /> =nc Versions=<br /> One thing that you have to realize is that there are more versions of netcat than there are versions of linux. Ok maybe that is a stretch, but it seems that every system that I use has a different version with different options or worse same option that acts differently. This is generally not an issue if you use the main versions of linux as they have come to use the same version. However, if you are using embedded linux with busybox, then make sure you look at the help to get the options. In general I recommend always looking at the help of nc(netcat) just to make sure, because I am constantly getting confused on which options to use on this command. <br /> <br /> There is also some windows versions that have with or without the -e option that is considered a gaping security hole, which is really quite over blown considering the other utilites that can do the same thing. But the claim on the securlty issue is quite ridiculas considering that you can still accomplish the same task using fifo's on linux. Windows is not as easy considering that you do not have the ability to create a fifo so easily from the command line. If you plan on using Windows, make sure you get the version with the -e aka - Gaping Security Hole.<br /> <br /> =Assumptions=<br /> * You have basic knowledge of command line usage <br /> * You know how to load a program to the Arduino<br /> <br /> =Linux=<br /> Here is the one line linux command that will send the serial terminal /dev/ttyUSB0 to a network TCP port:<br /> mkfifo arduino_fifo; nc -lk 2111 &lt;arduino_fifo | plink -serial /dev/ttyUSB0 -sercfg 115200,8,n,1,n &gt;arduino_fifo &amp;<br /> Before you start asking, plink is a command that is downloaded witht the putty pacakge. Since I use windows and linux quite often, I decided to stick with putty as a multi-use package. It is easy to download and you can get it from any major linux distribution with the package manager that meets your linux distribution. You could just as easily replace putty with minicom or screen. I will leave it to the user to figure out which serial communication software to use.<br /> <br /> To explain the basis of this command we are redirecting inputs and outputs to get the information to the TCP port by looping back on a fifo (named pipe). So after you run this command you will able to connect to the port and communicate back and forth with the arduino. From another computer on your network, here is how you would connect to the port:<br /> <br /> nc 192.168.30.208 2111<br /> <br /> You would put the ip of the computer you have the Arduino connected to and port 2111 it the port we used on the nc command to send the data through that port. When you press enter on that command you will have direct access to that arduino and it's serial port through the network. Now you can access that port from wherever you are on the internet if you have access your network. I encourage you to use VPN's or ssh to securly access this port and do not just put it out on the web. <br /> <br /> =Mini2440 or Embedded Systems=<br /> Embedded systems like the Mini2440, use Busy Box as a small utility package that includes a version of nc that makes communications to Arduino a breeze. All you have to do is go to a terminal and use these two commands after you plug in the Arduino.<br /> <br /> stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> nc -f /dev/ttyUSB0<br /> <br /> You should now have a terminal session that is communicating with the Arduino. Of course you should have a program that responds to serial communication on the Arduino, or nothing will be happening. How this works is the ''nc'' command has redirected the input and output streams of the /dev/ttyUSB0, which is the Arduino terminal and the ''stty'' command sets the serial communication parameters. To exit out of the program, just use ''^C (ctrl-c)''<br /> <br /> <br /> Now we expand on this idea and we send the Arduino serial port to a network port with this command. <br /> <br /> nc -ll -p 2111 -e nc -f /dev/ttyUSB0<br /> <br /> This is where it gets interesting. Now you can access your Arduino from anywhere on the planet, or space if you still have a good satellite connection `,~) Use this command from any other computer that has ''netcat''.<br /> <br /> nc 192.168.30.206 2111<br /> <br /> Use the ip of your Mini2440 of course.</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Communications_Using_the_netcat(nc)_Utility Arduino Communications Using the netcat(nc) Utility 2012-11-08T19:20:14Z <p>Jvaughters: </p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> &lt;!--------------------------------Featured picture------------------------------<br /> {| id=&quot;mp-tfp&quot; style=&quot;margin:4px 0px 0px 0px; width:30%; background:none;&quot;<br /> |class=&quot;MainPageBG&quot; style=&quot;width:30%; border:1px solid #ddcef2; background:#faf5ff; vertical-align:top; color:#000;&quot;|<br /> {| cellpadding=&quot;2&quot; cellspacing=&quot;5&quot; style=&quot;vertical-align:top; background:#faf5ff; color:#000; width:30%&quot;<br /> ! &lt;h3 id=&quot;mp-tfp-h2&quot; style=&quot;margin:0; background:#ddcef2; font-size:120%; font-weight:bold; border:1px solid #afa3bf; text-align:top; color:#000; padding:0.2em 0.4em&quot;&gt;Featured picture&lt;/h3&gt;<br /> |-<br /> |style=&quot;color:#000;&quot;| {{Featured Picture}}<br /> |}<br /> |}&lt;!--<br /> <br /> <br /> <br /> &lt;---------Interwiki strapline----------&gt;<br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> =Overview=<br /> Why reinvent the wheel. I have seen very complicated methods for communicating with the Arduino, Including some I have made on my own. What I have recently found out is that the easiest way to communicate to the Arduino is using the existing tool ''netcat''. It is soooooo simple and super powerful. You can send the output to a Network port and access the communications from literally any place in the world. <br /> <br /> =nc Versions=<br /> One thing that you have to realize is that there are more versions of netcat than there are versions of linux. Ok maybe that is a stretch, but it seems that every system that I use has a different version with different options or worse same option that acts differently. This is generally not an issue if you use the main versions of linux as they have come to use the same version. However, if you are using embedded linux with busybox, then make sure you look at the help to get the options. In general I recommend always looking at the help of nc(netcat) just to make sure, because I am constantly getting confused on which options to use on this command. <br /> <br /> There is also some windows versions that have with or without the -e option that is considered a gaping security hole, which is really quite over blown considering the other utilites that can do the same thing. But the claim on the securlty issue is quite ridiculas considering that you can still accomplish the same task using fifo's on linux. Windows is not as easy considering that you do not have the ability to create a fifo so easily from the command line. If you plan on using Windows, make sure you get the version with the -e aka - Gaping Security Hole.<br /> <br /> =Assumptions=<br /> * You have basic knowledge of command line usage <br /> * You know how to load a program to the Arduino<br /> <br /> =Linux=<br /> <br /> =Mini2440 or Embedded Systems=<br /> Embedded systems like the Mini2440, use Busy Box as a small utility package that includes a version of nc that makes communications to Arduino a breeze. All you have to do is go to a terminal and use these two commands after you plug in the Arduino.<br /> <br /> stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> nc -f /dev/ttyUSB0<br /> <br /> You should now have a terminal session that is communicating with the Arduino. Of course you should have a program that responds to serial communication on the Arduino, or nothing will be happening. How this works is the ''nc'' command has redirected the input and output streams of the /dev/ttyUSB0, which is the Arduino terminal and the ''stty'' command sets the serial communication parameters. To exit out of the program, just use ''^C (ctrl-c)''<br /> <br /> <br /> Now we expand on this idea and we send the Arduino serial port to a network port with this command. <br /> <br /> nc -ll -p 2111 -e nc -f /dev/ttyUSB0<br /> <br /> This is where it gets interesting. Now you can access your Arduino from anywhere on the planet, or space if you still have a good satellite connection `,~) Use this command from any other computer that has ''netcat''.<br /> <br /> nc 192.168.30.206 2111<br /> <br /> Use the ip of your Mini2440 of course.</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-08T15:35:32Z <p>Jvaughters: </p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> <br /> =Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process requires a tftp server. If you decide to use this process then you will need to install that software first. I originally had some long instructions, but I decided to create a script, which is still long, so I moved it to this page: [[Arduino Sever PXE Script]]<br /> ====Operation====<br /> At this stage you should have the server working and we will test it and connect to the arduino from a client.<br /> <br /> Test Server:<br /> * Log into the server from the console or ssh<br /> * Verify that the /home/scada/scripts/arduino_init script worked with this command<br /> netstat -tl<br /> Expected command ouput:<br /> Active Internet connections (only servers)<br /> Proto Recv-Q Send-Q Local Address Foreign Address State <br /> tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN <br /> tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN <br /> netstat: /proc/net/tcp6: No such file or directory<br /> This shows the port 2111 we are looking for to show that the arduino_init script worked. If you do not see that line, then it did not work.<br /> * Try to manually run socat command: (Note:This resets the program in Arduino after a reconnect to port)<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> If this fails, then check that /dev/arduino_1 exists, it may be a udev naming issue. See this article for assitance with udev: [[Arduino Communications Device Naming with udev]]<br /> * Connect to TCP port 2111 from another computer (If you have trouble try this as root)<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 172.1.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> =More Investigation=<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Electronics Arduino Electronics 2012-11-08T15:35:02Z <p>Jvaughters: </p> <hr /> <div>&lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc.html&lt;/anyweb&gt;<br /> <br /> {{default}}<br /> <br /> &lt;anyweb&gt;http://combustory.com/wiki/ads/ad_rtc_1.html&lt;/anyweb&gt;<br /> == Summary ==<br /> <br /> Arduino is an open-source hardware platform. It is a micro controller with a free development environment that is greatly simplified for programming the controller. Visit this website for further details, http://www.arduino.cc/<br /> <br /> == Topics ==<br /> <br /> * [[Arduino Communications]] - Communication through files in a distributed network approach<br /> * [[Arduino Communications - SQLite]] - Load Arduino Data into an SQLite database<br /> * [[Arduino Communications Using the netcat(nc) Utility]] - Create a TCP network connection to your serial device<br /> * [[Arduino Communications Device Naming with udev]] - Learn how to name your device so you can reliably connect to the same Arduino<br /> * [[Arduino Server]] - Arduino Terminal server (Network to Serial) using old hardware and TinyCore Linux<br /> * [[Temperature Controller]] - A/C control for multi-room space with air duct throttling (ie. Smart Thermostat)<br /> * [[X9241A - Digital Potentiometer]] - Arduino code for using I2C to control this Digital Potentiometer<br /> * [[MPGuino]] - An MPG gauge based on the Arduino Platform<br /> * [[RTC1307 - Real Time Clock]] - Arduino code for using I2C to control this Real Time Clock<br /> * [[Linux, Apple, or Windows - Which one is right for you?]] - This really does not belong in this section, but I just wanted a place holder to send people for now as this is a very common question that I get.<br /> * Suggestions Welcome<br /> <br /> == Links ==<br /> [[Category:Electronics]]</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-08T02:10:45Z <p>Jvaughters: /* Configuration */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process requires a tftp server. If you decide to use this process then you will need to install that software first. I originally had some long instructions, but I decided to create a script, which is still long, so I moved it to this page: [[Arduino Sever PXE Script]]<br /> ====Operation====<br /> At this stage you should have the server working and we will test it and connect to the arduino from a client.<br /> <br /> Test Server:<br /> * Log into the server from the console or ssh<br /> * Verify that the /home/scada/scripts/arduino_init script worked with this command<br /> netstat -tl<br /> Expected command ouput:<br /> Active Internet connections (only servers)<br /> Proto Recv-Q Send-Q Local Address Foreign Address State <br /> tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN <br /> tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN <br /> netstat: /proc/net/tcp6: No such file or directory<br /> This shows the port 2111 we are looking for to show that the arduino_init script worked. If you do not see that line, then it did not work.<br /> * Try to manually run socat command: (Note:This resets the program in Arduino after a reconnect to port)<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> If this fails, then check that /dev/arduino_1 exists, it may be a udev naming issue. See this article for assitance with udev: [[Arduino Communications Device Naming with udev]]<br /> * Connect to TCP port 2111 from another computer (If you have trouble try this as root)<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 172.1.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> =More Investigation=<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-08T01:30:31Z <p>Jvaughters: /* Configuration */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process requires a tftp server. If you decide to use this process then you will need to install that software first. I originally had some long instructions, but I decided to create a script, which is still long, so I moved it to this page: [[Arduino Sever PXE Script]]<br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using socat command<br /> * Verify that the /home/scada/scripts/arduino_init script worked with this command<br /> netstat -tl<br /> Expected command ouput:<br /> Active Internet connections (only servers)<br /> Proto Recv-Q Send-Q Local Address Foreign Address State <br /> tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN <br /> tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN <br /> netstat: /proc/net/tcp6: No such file or directory<br /> This shows the port 2111 we are looking for to show that the arduino_init script worked. If you do not see that line, then it did not work.<br /> * Try to manually run socat command: (Note:This resets the program in Arduino after a reconnect to port)<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> If this fails, then check that /dev/arduino_1 exists, it may be a udev naming issue<br /> * Connect to TCP port 2111 from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 172.1.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-08T01:06:04Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up and the computer is useful even in this state, but I believe you will find it beneficial to make some more changes. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> ===Best Practices===<br /> If you have created a bootable PXE system, then you are off to a great start. Since the configuration part can take some time, you may want to save the file periodically. That way if you make a mistake, you do not loose all your effort. Fortunately this is a breeze. You only need to copy one file. In a jam, you can extract this file and create known good root file system.<br /> <br /> * Create backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz.bak<br /> * restore the backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/core_root<br /> rm -rf /tftpboot/tc_pxe/tc_pxe_dev/core_root/*<br /> zcat ../ard-core.gz.bak | sudo cpio -i -H newc -d<br /> <br /> ===Create New Root File System===<br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> If you plan on using this server for more than just an [[Arduino Server]] I recommend you configure ssh, which I included in the additional packages. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> * Log into your TinyCore computer via ssh (Change ip's to match your network, accept ssh key and enter password), then copy key files over via scp<br /> ssh tc@192.168.1.150<br /> sudo scp /etc/dropbear/dropbear_dss_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/<br /> sudo scp /etc/dropbear/dropbear_rsa_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/ <br /> exit<br /> * Update the root file system per instructions above. <br /> * Next time you reboot, you should be able to access ssh without accepting a key<br /> <br /> ==Change the tc_pxe directory name==<br /> You may want to use your own directory names and if you want to have multiple computers using different images, then you will want to consider changing the tc_pxe directory name.<br /> <br /> * Change directory to ard_srv_1 from tc_pxe<br /> sed -i 's/tc_pxe/ard_srv_1/g' /tftpboot/tc_pxe/cde/onboot_x.lst<br /> sed -i 's/tc_pxe/ard_srv_1/g' /tftpboot/tc_pxe/pxelinux.cfg/default<br /> cd /tftpboot<br /> mv tc_pxe ard_srv_1<br /> * Point your PXE set up to the new directory and you are good to go.<br /> <br /> ==Other Configuration Ideas==<br /> * Use multiple servers with different image directories. Study how to boot PXE by MAC address.<br /> * Add packages to the PXE server. <br /> <br /> =Troubleshooting=<br /> <br /> <br /> ==Replace PXE TinyCore System==<br /> The best part of using TinyCore and this script is that if for some reason you messed up, you just start from scratch and it only takes a few minutes to run the script again as long as you do not delete the tc_downloads directory. It is even more useful if you had a running system from the start, then messed it up, then all you have to do is delete the /tftpboot/tc_pxe directory and then copy it from the ~/my_tinycore_dir directory.<br /> * Remove PXE set up and replace it with the default system created by script<br /> rm -rf /tftpboot/tc_pxe<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * More drastic measure to remove the default system and re-run script<br /> rm -rf ~/my_tinycore_dir/tc_pxe<br /> cd ~/my_tinycore_dir<br /> ./tc_pxe_script<br /> <br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-06T03:25:03Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up and the computer is useful even in this state, but I believe you will find it beneficial to make some more changes. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> ===Best Practices===<br /> If you have created a bootable PXE system, then you are off to a great start. Since the configuration part can take some time, you may want to save the file periodically. That way if you make a mistake, you do not loose all your effort. Fortunately this is a breeze. You only need to copy one file. In a jam, you can extract this file and create known good root file system.<br /> <br /> * Create backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz.bak<br /> * restore the backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/core_root<br /> rm -rf /tftpboot/tc_pxe/tc_pxe_dev/core_root/*<br /> zcat ../ard-core.gz.bak | sudo cpio -i -H newc -d<br /> <br /> ===Create New Root File System===<br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> If you plan on using this server for more than just an [[Arduino Server]] I recommend you configure ssh, which I included in the additional packages. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> * Log into your TinyCore computer via ssh (Change ip's to match your network, accept ssh key and enter password), then copy key files over via scp<br /> ssh tc@192.168.1.150<br /> sudo scp /etc/dropbear/dropbear_dss_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/<br /> sudo scp /etc/dropbear/dropbear_rsa_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/ <br /> exit<br /> * Update the root file system per instructions above. <br /> * Next time you reboot, you should be able to access ssh without accepting a key<br /> ==Add Packages to the server==<br /> There are literally tons of packages that can be added to the server. I am sure I will be adding more as I go along. This is how you add packages to your PXE server.<br /> <br /> * Go to this address and look for packages you would like to add - http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/<br /> * Find the package you are interested in adding and you will see several files for each package<br /> ** .info - This is a brief description of the package<br /> ** .dep - This file is very important if it exists. You need to download this file and download the packages you find in the file as well as any dependencies that those packages need as well.<br /> ** .md5.txt - This file can be used to verify the file after downloaded. I will leave it to the reader to investigate.<br /> ** .tcz - This is the actual package you need to download<br /> * We will use the vino.tcz package as an example. <br /> <br /> ==Change the tc_pxe directory name==<br /> You may want to use your own directory names and if you want to have multiple computers using different images, then you will want to consider changing the tc_pxe directory name.<br /> <br /> * Change directory to ard_srv_1 from tc_pxe<br /> sed -i 's/tc_pxe/ard_srv_1/g' /tftpboot/tc_pxe/cde/onboot_x.lst<br /> sed -i 's/tc_pxe/ard_srv_1/g' /tftpboot/tc_pxe/pxelinux.cfg/default<br /> cd /tftpboot<br /> mv tc_pxe ard_srv_1<br /> * Point your PXE set up to the new directory and you are good to go.<br /> <br /> ==Other Configuration Ideas==<br /> * Use multiple servers with different image directories. Study how to boot PXE by MAC address.<br /> *<br /> <br /> =Troubleshooting=<br /> <br /> <br /> ==Replace PXE TinyCore System==<br /> The best part of using TinyCore and this script is that if for some reason you messed up, you just start from scratch and it only takes a few minutes to run the script again as long as you do not delete the tc_downloads directory. It is even more useful if you had a running system from the start, then messed it up, then all you have to do is delete the /tftpboot/tc_pxe directory and then copy it from the ~/my_tinycore_dir directory.<br /> * Remove PXE set up and replace it with the default system created by script<br /> rm -rf /tftpboot/tc_pxe<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * More drastic measure to remove the default system and re-run script<br /> rm -rf ~/my_tinycore_dir/tc_pxe<br /> cd ~/my_tinycore_dir<br /> ./tc_pxe_script<br /> <br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-06T01:50:32Z <p>Jvaughters: /* Change the tc_pxe directory name */</p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up and the computer is useful even in this state, but I believe you will find it beneficial to make some more changes. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> ===Best Practices===<br /> If you have created a bootable PXE system, then you are off to a great start. Since the configuration part can take some time, you may want to save the file periodically. That way if you make a mistake, you do not loose all your effort. Fortunately this is a breeze. You only need to copy one file. In a jam, you can extract this file and create known good root file system.<br /> <br /> * Create backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz.bak<br /> * restore the backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/core_root<br /> rm -rf /tftpboot/tc_pxe/tc_pxe_dev/core_root/*<br /> zcat ../ard-core.gz.bak | sudo cpio -i -H newc -d<br /> <br /> ===Create New Root File System===<br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> If you plan on using this server for more than just an [[Arduino Server]] I recommend you configure ssh, which I included in the additional packages. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> * Log into your TinyCore computer via ssh (Change ip's to match your network, accept ssh key and enter password), then copy key files over via scp<br /> ssh tc@192.168.1.150<br /> sudo scp /etc/dropbear/dropbear_dss_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/<br /> sudo scp /etc/dropbear/dropbear_rsa_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/ <br /> exit<br /> * Update the root file system per instructions above. <br /> * Next time you reboot, you should be able to access ssh without accepting a key<br /> ==Add Packages to the server==<br /> There are literally tons of packages that can be added to the server. I am sure I will be adding more as I go along. This is how you add packages to your PXE server.<br /> <br /> * Go to this address and look for packages you would like to add - http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/<br /> * Find the package you are interested in adding and you will see several files for each package<br /> ** .info - This is a brief description of the package<br /> ** .dep - This file is very important if it exists. You need to download this file and download the packages you find in the file as well as any dependencies that those packages need as well.<br /> ** .md5.txt - This file can be used to verify the file after downloaded. I will leave it to the reader to investigate.<br /> ** .tgz - This is the actual package you need to download<br /> <br /> ==Change the tc_pxe directory name==<br /> You may want to use your own directory names and if you want to have multiple computers using different images, then you will want to consider changing the tc_pxe directory name.<br /> <br /> * Change directory to ard_srv_1 from tc_pxe<br /> sed -i 's/tc_pxe/ard_srv_1/g' /tftpboot/tc_pxe/cde/onboot_x.lst<br /> sed -i 's/tc_pxe/ard_srv_1/g' /tftpboot/tc_pxe/pxelinux.cfg/default<br /> cd /tftpboot<br /> mv tc_pxe ard_srv_1<br /> * Point your PXE set up to the new directory and you are good to go.<br /> <br /> ==Other Configuration Ideas==<br /> * Use multiple servers with different image directories. Study how to boot PXE by MAC address.<br /> *<br /> <br /> =Troubleshooting=<br /> <br /> <br /> ==Replace PXE TinyCore System==<br /> The best part of using TinyCore and this script is that if for some reason you messed up, you just start from scratch and it only takes a few minutes to run the script again as long as you do not delete the tc_downloads directory. It is even more useful if you had a running system from the start, then messed it up, then all you have to do is delete the /tftpboot/tc_pxe directory and then copy it from the ~/my_tinycore_dir directory.<br /> * Remove PXE set up and replace it with the default system created by script<br /> rm -rf /tftpboot/tc_pxe<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * More drastic measure to remove the default system and re-run script<br /> rm -rf ~/my_tinycore_dir/tc_pxe<br /> cd ~/my_tinycore_dir<br /> ./tc_pxe_script<br /> <br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-06T00:13:37Z <p>Jvaughters: /* Replace PXE TinyCore System */</p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up and the computer is useful even in this state, but I believe you will find it beneficial to make some more changes. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> ===Best Practices===<br /> If you have created a bootable PXE system, then you are off to a great start. Since the configuration part can take some time, you may want to save the file periodically. That way if you make a mistake, you do not loose all your effort. Fortunately this is a breeze. You only need to copy one file. In a jam, you can extract this file and create known good root file system.<br /> <br /> * Create backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz.bak<br /> * restore the backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/core_root<br /> rm -rf /tftpboot/tc_pxe/tc_pxe_dev/core_root/*<br /> zcat ../ard-core.gz.bak | sudo cpio -i -H newc -d<br /> <br /> ===Create New Root File System===<br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> If you plan on using this server for more than just an [[Arduino Server]] I recommend you configure ssh, which I included in the additional packages. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> * Log into your TinyCore computer via ssh (Change ip's to match your network, accept ssh key and enter password), then copy key files over via scp<br /> ssh tc@192.168.1.150<br /> sudo scp /etc/dropbear/dropbear_dss_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/<br /> sudo scp /etc/dropbear/dropbear_rsa_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/ <br /> exit<br /> * Update the root file system per instructions above. <br /> * Next time you reboot, you should be able to access ssh without accepting a key<br /> ==Change the tc_pxe directory name==<br /> You may want to use your own directory names and if you want to have multiple computers using different images, then you will want to consider changing the tc_pxe directory name. <br /> <br /> TODO: I need to outline all the changes to the scripts<br /> <br /> =Troubleshooting=<br /> <br /> <br /> ==Replace PXE TinyCore System==<br /> The best part of using TinyCore and this script is that if for some reason you messed up, you just start from scratch and it only takes a few minutes to run the script again as long as you do not delete the tc_downloads directory. It is even more useful if you had a running system from the start, then messed it up, then all you have to do is delete the /tftpboot/tc_pxe directory and then copy it from the ~/my_tinycore_dir directory.<br /> * Remove PXE set up and replace it with the default system created by script<br /> rm -rf /tftpboot/tc_pxe<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * More drastic measure to remove the default system and re-run script<br /> rm -rf ~/my_tinycore_dir/tc_pxe<br /> cd ~/my_tinycore_dir<br /> ./tc_pxe_script<br /> <br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-06T00:10:50Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up and the computer is useful even in this state, but I believe you will find it beneficial to make some more changes. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> ===Best Practices===<br /> If you have created a bootable PXE system, then you are off to a great start. Since the configuration part can take some time, you may want to save the file periodically. That way if you make a mistake, you do not loose all your effort. Fortunately this is a breeze. You only need to copy one file. In a jam, you can extract this file and create known good root file system.<br /> <br /> * Create backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz.bak<br /> * restore the backup of root file system<br /> cd /tftpboot/tc_pxe/tc_pxe_dev/core_root<br /> rm -rf /tftpboot/tc_pxe/tc_pxe_dev/core_root/*<br /> zcat ../ard-core.gz.bak | sudo cpio -i -H newc -d<br /> <br /> ===Create New Root File System===<br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> If you plan on using this server for more than just an [[Arduino Server]] I recommend you configure ssh, which I included in the additional packages. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> * Log into your TinyCore computer via ssh (Change ip's to match your network, accept ssh key and enter password), then copy key files over via scp<br /> ssh tc@192.168.1.150<br /> sudo scp /etc/dropbear/dropbear_dss_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/<br /> sudo scp /etc/dropbear/dropbear_rsa_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/ <br /> exit<br /> * Update the root file system per instructions above. <br /> * Next time you reboot, you should be able to access ssh without accepting a key<br /> ==Change the tc_pxe directory name==<br /> You may want to use your own directory names and if you want to have multiple computers using different images, then you will want to consider changing the tc_pxe directory name. <br /> <br /> TODO: I need to outline all the changes to the scripts<br /> <br /> =Troubleshooting=<br /> <br /> <br /> ==Replace PXE TinyCore System==<br /> The best part of using TinyCore and this script is that if for some reason you messed up, you just start from scratch and it only takes a few minutes to run the script again as long as you do not delete the tc_downloads directory. Even more useful is if you had a running system from the start, then messed it up, all you have to do is delete the tc_pxe directory in the tftpboot directory and then copy it from the ~/my_tinycore_dir directory.<br /> * Remove PXE set up and replace it with the default system created by script<br /> rm -rf /tftpboot/tc_pxe<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * More drastic measure to remove the default system and re-run script<br /> rm -rf ~/my_tinycore_dir/tc_pxe<br /> cd ~/my_tinycore_dir<br /> ./tc_pxe_script<br /> <br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-05T23:23:29Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up and the computer is useful even in this state, but I believe you will find it beneficial to make some more changes. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> ==Best Practices==<br /> If you have created a bootable PXE system, then you are off to a great start. Since the configuration part can take some time, you may want to save the file periodically. That way if you make a mistake, you do not loose all your effort. Fortunately this is a breeze. You only need to copy one file. In a jam, you can extract this file and create known good root file system.<br /> <br /> cd /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz /tftpboot/tc_pxe/tc_pxe_dev/ard-core.gz.bak<br /> <br /> <br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> If you plan on using this server for more than just an [[Arduino Server]] I recommend you configure ssh, which I included in the additional packages. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> * Log into your TinyCore computer via ssh (Change ip's to match your network, accept ssh key and enter password), then copy key files over via scp<br /> ssh tc@192.168.1.150<br /> sudo scp /etc/dropbear/dropbear_dss_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/<br /> sudo scp /etc/dropbear/dropbear_rsa_host_key root@192.168.1.1:/tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear/ <br /> exit<br /> * Update the root file system per instructions above. <br /> * Next time you reboot, you should be able to access ssh without accepting a key<br /> ==Change the tc_pxe directory name==<br /> You may want to use your own directory names and if you want to have multiple computers using different images, then you will want to consider changing the tc_pxe directory name. <br /> <br /> TODO: I need to outline all the changes to the scripts<br /> <br /> =Troubleshooting=<br /> <br /> <br /> ==Replace PXE TinyCore System==<br /> The best part of using TinyCore and this script is that if for some reason you messed up, you just start from scratch and it only takes a few minutes to run the script again as long as you do not delete the tc_downloads directory. Even more useful is if you had a running system from the start, then messed it up, all you have to do is delete the tc_pxe directory in the tftpboot directory and then copy it from the ~/my_tinycore_dir directory.<br /> * Remove PXE set up and replace it with the default system created by script<br /> rm -rf /tftpboot/tc_pxe<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * More drastic measure to remove the default system and re-run script<br /> rm -rf ~/my_tinycore_dir/tc_pxe<br /> cd ~/my_tinycore_dir<br /> ./tc_pxe_script<br /> <br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-05T02:22:08Z <p>Jvaughters: /* ssh via dropbear */</p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> If you plan on using this server for more than just an [[Arduino Server]] I recommend you configure ssh, which I included in the additional packages. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> scp <br /> Unfinished<br /> <br /> =Troubleshooting=<br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-05T02:12:16Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> I personally plan on using this server for more than just an [[Arduino Server]] so I have included ssh in this set up. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> mkdir /tftboot/tc_pxe/tc_pxe_dev/core_root/etc/dropbear<br /> scp <br /> Unfinished<br /> <br /> =Troubleshooting=<br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-05T02:06:52Z <p>Jvaughters: /* ssh via dropbear */</p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> I personally plan on using this server for more than just an [[Arduino Server]] so I have included ssh in this set up. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> <br /> Unfinished<br /> <br /> =Troubleshooting=<br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-05T01:27:20Z <p>Jvaughters: /* TinyCore PXE build script */</p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> I personally plan on using this server for more than just an [[Arduino Server]] so I have included ssh in this set up. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> <br /> =Troubleshooting=<br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1 &amp;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-04T21:37:27Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> I personally plan on using this server for more than just an [[Arduino Server]] so I have included ssh in this set up. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users (Enter password when promted)<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> <br /> =Troubleshooting=<br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-04T21:05:16Z <p>Jvaughters: /* ssh via dropbear */</p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> I personally plan on using this server for more than just an [[Arduino Server]] so I have included ssh in this set up. You can also use ssh to transfer files that can be used as a method other than the default set up of connecting the serial ports to a network TCP port. To use ssh on TinyCore linux, we have loaded a package called dropbear. We will need to change our root file system to create passwords for the tc and root users. We will also want to copy over the server identifying keys to prevent new keys every time the server reboots. This can be quite annoying when trying to access the server and getting rejected because of the keys.<br /> <br /> Steps to use ssh:<br /> * Make sure you have root access<br /> * Set the passwords of tc and root users<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd tc<br /> chroot /tftpboot/tc_pxe/tc_pxe_dev/core_root/ passwd root<br /> * If your Tiny Core system is already booted, then we can transfer over the keys to the root file system with scp<br /> <br /> =Troubleshooting=<br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-04T20:36:55Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> Note:This page is related to the [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move the created directory to the /tftpboot directory and point your dhcp server to the new directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but I will let you investigate anything outside of the [Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to the ip address of your tftp server<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe /tftpboot/tc_pxe<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> <br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up. In this section we will discuss how to modify your system further to make the it even more useful.<br /> <br /> ==Root File System==<br /> Any changes you make on the server are not kept once you reboot. To change any files on the root file system you will need to change it in the ''/tftboot/tc_pxe/tc_pxe_dev/core_root'' directory. This is the root directory for your server. Then you will need to run a script to compact the root file system and copy it to your ''/tftpboot/tc_pxe'' directory. You can also use chroot commands to modify settings that that are needed to be done root access.<br /> <br /> How to change files in your root file system:<br /> * Make sure you have root access<br /> * Make any changes like adding files, changing files or chroot commands<br /> * Once you are finished with your changes run these commands<br /> cd /tftpboot/tc_pxe/tc_pxe_dev<br /> ./build_tinycore<br /> * Your new file system changes will show on the next reboot<br /> <br /> ==Arduino Naming with udev==<br /> If you plan on hosting more than one Arduino device on this server, then you need consider naming the device with udev. This is probably the most useful feature for making sure that your Arduino devices get named the same at boot up so you can access the correct Arduino with the correct script. The default set up should work with an Arduino Deciemilla. It will name the serial device ''/dev/arduino_1''. Even if I only have one device, I find it rather convenient to use for finding my devices. <br /> <br /> How to change the device names of your Arduinos (Or any other USB to Serial Device):<br /> * I highly recommend you visit the [[Arduino Communications Device Naming with udev]] article to help you understand<br /> * Below is the file you will want to modify to match up your devices<br /> /tftpboot/tc_pxe/tc_pxe_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> * Example entry in the file. Changing the attributes and the NAME will be most important. You do not want duplicate names.<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * Once you have made the changes to the files, follow the instructions on updating the root file system above. <br /> <br /> TIP: You probably will want to test on any other linux computer to get your settings correct and then copy the settings to your tc_pxe root file system. Otherwise you will spend much time changing and rebooting your system. <br /> <br /> ==ssh via dropbear==<br /> <br /> <br /> =Troubleshooting=<br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core_root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-04T19:39:46Z <p>Jvaughters: </p> <hr /> <div>=Introduction=<br /> Note:This page is related to [[Arduino Server]] article. Without reading that article, this one will probably not make much sense.<br /> <br /> This article provides instructions to build a complete PXE directory for the [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux] Distribution. You will be able to run the script below and then move it directly to the /tftpboot directory and point your dhcp server to that directory. This will allow you to boot a wide range of computers via the network. The script is focused on taking care of the details to configure an [[Arduino Server]] that basically acts as a terminal server for connected Arduinos. The server is much more capable than just serving Arduinos, but that I will let you investigate anything outside of the [[Arduino Server]] focus.<br /> <br /> =Assumptions=<br /> * You have access to the internet<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure PXE booting<br /> * You have a tfpt server running<br /> * You understand sudo, su, chroot commands<br /> <br /> =Instructions=<br /> Note: These instructions were tested on Fedora 13, but should run on typical linux distributions <br /> * Become root user. All commands below assume root access<br /> * Create a directory to use for PXE development and change into the directory<br /> mkdir ~/my_tinycore_dir<br /> cd ~/my_tinycore_dir<br /> * Create a file and copy the contents of the script below<br /> gedit tc_pxe_build<br /> * Find the text '''tftplist=192.168.1.1''' in your script and change it to your ip address<br /> * Save the script and make it executable by root only<br /> chmod 700 tc_pxe_build<br /> * Run the script. It will download what it needs and create necessary directories<br /> ./tc_pxe_script<br /> * The follwing directories will be created. Keep all the directories, because you may want to run the script multiple times<br /> ** tc_downloads - This is where the files needed are downloaded<br /> ** tc_pxe - This is the directory that is ready to be moved to /tftpboot<br /> ** tc_pxe_mnt - Just a temporary directory to mount the iso file<br /> * Copy the tc_pxe directory to the /tftpboot directory (You should not change the directory name, it has other references to it)<br /> cp -r ~/my_tinycore_dir/tc_pxe/ /tftpboot/<br /> * Point your PXE settings to this directory <br /> * Set up the BIOS on the computer you want to boot and you should be able to boot just about any PC that has netboot capability<br /> =Further Configuration=<br /> Hopefully you were able to get a server running. That is a big part of this set up. In this section we will discuss how to modify your system further to make the it even more useful.<br /> =Troubleshooting=<br /> =TinyCore PXE build script=<br /> &lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://combustory.com/wiki/index.php/Arduino_Sever_PXE_Script<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core-root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Sever_PXE_Script Arduino Sever PXE Script 2012-11-04T18:23:09Z <p>Jvaughters: Created page with &quot;&lt;source lang=&quot;bash&quot;&gt; #/bin/bash #tc_pxe_build v0.1 # Written by John Vaughters at http://www.combustory.com # This script will build the entire pxe directory structure needed to ...&quot;</p> <hr /> <div>&lt;source lang=&quot;bash&quot;&gt;<br /> #/bin/bash<br /> #tc_pxe_build v0.1<br /> # Written by John Vaughters at http://www.combustory.com<br /> # This script will build the entire pxe directory structure needed to start a tinycore arduino server<br /> <br /> # Check if already installed<br /> if [ -d tc_pxe ]<br /> then<br /> echo '********************* Directory tc_pxe already exists. Please remove tc_pxe directory to run this Intall'<br /> exit 0<br /> fi<br /> <br /> # Create Directories<br /> echo '*********************Creating Directories'<br /> <br /> mkdir tc_downloads<br /> mkdir tc_pxe_mnt<br /> mkdir tc_pxe<br /> mkdir tc_pxe/pxelinux.cfg<br /> mkdir tc_pxe/tc_pxe_dev<br /> mkdir tc_pxe/tc_pxe_dev/core_root<br /> <br /> <br /> # Download and copy TinyCore<br /> echo '*********************Downloading, Extracting and Copying TinyCore-current.iso'<br /> <br /> cd tc_downloads<br /> if [ ! -f TinyCore-current.iso ] <br /> then<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/release/TinyCore-current.iso<br /> fi<br /> mount TinyCore-current.iso ../tc_pxe_mnt -o loop,ro<br /> cp -r ../tc_pxe_mnt/* ../tc_pxe<br /> umount ../tc_pxe_mnt<br /> cp ../tc_pxe/boot/core.gz ../tc_pxe/tc_pxe_dev<br /> cd ../tc_pxe/tc_pxe_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> <br /> # Make directories and scripts for arduino initialization<br /> echo '*********************Build new rootfs and add scripts for PXE boot'<br /> <br /> mkdir home/scada<br /> mkdir home/scada/scripts<br /> mkdir home/scada/data<br /> echo '#!/bin/bash' &gt; home/scada/scripts/arduino_init<br /> echo '# arduino_init - initialization tasks for scada' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '### Main script starts here ###' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Store file name of arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'FILE=&quot;/dev/arduino_1&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' ' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# Arduino Communications' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# set serial commuication for arduino' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts' &gt;&gt; home/scada/scripts/arduino_init<br /> echo '# make sure file (serial device) exist and is readable' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE is not logging&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' if [ ! -c $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE : does not exists&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' elif [ ! -r $FILE ]; then' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;$FILE: can not read&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' exit 2' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' else' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;' &gt;&gt; home/scada/scripts/arduino_init<br /> echo ' fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'fi' &gt;&gt; home/scada/scripts/arduino_init<br /> echo 'exit 0' &gt;&gt; home/scada/scripts/arduino_init<br /> chmod 755 home/scada/scripts/arduino_init<br /> <br /> # Add services to the boot script<br /> echo '/etc/init.d/dropbear start' &gt;&gt; opt/bootlocal.sh<br /> echo 'sh /home/scada/scripts/arduino_init &amp;' &gt;&gt; opt/bootlocal.sh<br /> echo 'SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;' &gt; etc/udev/rules.d/98-arduino.rules<br /> <br /> # Build tiny_core rootfs<br /> find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz ../boot/<br /> <br /> # Create build_tinycore script<br /> echo 'cd core-root' &gt; build_tinycore<br /> echo 'find | cpio -o -H newc | gzip -2 &gt; ../ard-core.gz' &gt;&gt; build_tinycore<br /> echo 'cd ..' &gt;&gt; build_tinycore<br /> echo 'cp ard-core.gz ../boot/' &gt;&gt; build_tinycore<br /> chmod 700 build_tinycore<br /> <br /> # Download optional software packages<br /> echo '*********************Downloading Additional Packages for TinyCore'<br /> <br /> cd ../../tc_downloads<br /> # Get ssh dropbear<br /> if [ -f dropbear.tcz ] <br /> then<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> cp dropbear.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get net utility socat<br /> if [ -f socat.tcz ] <br /> then<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> cp socat.tcz ../tc_pxe/cde/optional/<br /> fi<br /> # Get usb to serial utility<br /> if [ -f usb-serial-3.0.21-tinycore.tcz ] <br /> then<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> else<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> cp usb-serial-3.0.21-tinycore.tcz ../tc_pxe/cde/optional/<br /> fi<br /> cd ../tc_pxe<br /> <br /> # Check if file exists before copy. If it does not exist then download the syslinux and extract<br /> if [ -f &quot;/usr/share/syslinux/pxelinux.0&quot; ]<br /> then<br /> cp /usr/share/syslinux/pxelinux.0 .<br /> else<br /> echo '*********************Unable to find /usr/share/syslinux/pxelinux.0 downloading syslinux'<br /> cd ../tc_downloads<br /> if [ ! -f &quot;syslinux-4.06/core/pxelinux.0&quot; ]<br /> then<br /> if [ ! -f &quot;syslinux-4.06.tar.gz&quot; ]<br /> then<br /> wget http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz<br /> fi<br /> tar -zxf syslinux-4.06.tar.gz<br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> else <br /> cp syslinux-4.06/core/pxelinux.0 ../tc_pxe/pxelinux.0<br /> fi <br /> cd ../tc_pxe<br /> fi<br /> cd pxelinux.cfg<br /> echo 'default boot/vmlinuz' &gt; default<br /> echo 'append initrd=boot/ard-core.gz tftplist=192.168.1.1:/tc_pxe/cde/onboot_x.lst xvesa=800x600x32' &gt;&gt; default <br /> cd ../cde<br /> echo '/tc_pxe/cde/optional/Xlibs.tcz' &gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xprogs.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/Xvesa.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/fltk-1.10.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/wbar.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/flwm_topside.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/usb-serial-3.0.21-tinycore.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/dropbear.tcz' &gt;&gt; onboot_x.lst<br /> echo '/tc_pxe/cde/optional/socat.tcz' &gt;&gt; onboot_x.lst<br /> <br /> echo '*********************Install Complete'<br /> &lt;/source&gt;</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-04T01:57:19Z <p>Jvaughters: /* Development Environment */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process requires a tftp server. If you decide to use this process then you will need to install that software first. <br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> touch /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines to the file:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> <br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image<br /> ** Create the following directory and file<br /> mkdir /tftpboot/tinycore/pxelinlux.cfg<br /> touch /tftpboot/tinycore/pxelinlux.cfg/default<br /> ** Put this text in the default file<br /> default boot/vmlinuz<br /> append initrd=boot/ard-core.gz tftplist=172.1.1.150:/tinycore/cde/onboot_x.lst xvesa=800x600x32<br /> ** Copy PXE boot file<br /> cp /usr/share/syslinux/pxelinux.0 /tftpboot/tinycore/<br /> ** If you cannot find pxelinux.0 file on your system then download syslinux from here:<br /> &lt;nowiki&gt; http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz&lt;/nowiki&gt;<br /> ** you will find pxelinux.0 file in /syslinux-4.06/core/ directory of the archive<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using socat command<br /> * Verify that the /home/scada/scripts/arduino_init script worked with this command<br /> netstat -tl<br /> Expected command ouput:<br /> Active Internet connections (only servers)<br /> Proto Recv-Q Send-Q Local Address Foreign Address State <br /> tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN <br /> tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN <br /> netstat: /proc/net/tcp6: No such file or directory<br /> This shows the port 2111 we are looking for to show that the arduino_init script worked. If you do not see that line, then it did not work.<br /> * Try to manually run socat command: (Note:This resets the program in Arduino after a reconnect to port)<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> If this fails, then check that /dev/arduino_1 exists, it may be a udev naming issue<br /> * Connect to TCP port 2111 from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 172.1.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-04T01:51:50Z <p>Jvaughters: /* PXE Setup */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process requires a tftp server. If you decide to use this process then you will need to install that software first. <br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image<br /> ** Create the following directory and file<br /> mkdir /tftpboot/tinycore/pxelinlux.cfg<br /> touch /tftpboot/tinycore/pxelinlux.cfg/default<br /> ** Put this text in the default file<br /> default boot/vmlinuz<br /> append initrd=boot/ard-core.gz tftplist=172.1.1.150:/tinycore/cde/onboot_x.lst xvesa=800x600x32<br /> ** Copy PXE boot file<br /> cp /usr/share/syslinux/pxelinux.0 /tftpboot/tinycore/<br /> ** If you cannot find pxelinux.0 file on your system then download syslinux from here:<br /> &lt;nowiki&gt; http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz&lt;/nowiki&gt;<br /> ** you will find pxelinux.0 file in /syslinux-4.06/core/ directory of the archive<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using socat command<br /> * Verify that the /home/scada/scripts/arduino_init script worked with this command<br /> netstat -tl<br /> Expected command ouput:<br /> Active Internet connections (only servers)<br /> Proto Recv-Q Send-Q Local Address Foreign Address State <br /> tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN <br /> tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN <br /> netstat: /proc/net/tcp6: No such file or directory<br /> This shows the port 2111 we are looking for to show that the arduino_init script worked. If you do not see that line, then it did not work.<br /> * Try to manually run socat command: (Note:This resets the program in Arduino after a reconnect to port)<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> If this fails, then check that /dev/arduino_1 exists, it may be a udev naming issue<br /> * Connect to TCP port 2111 from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 172.1.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-04T01:41:49Z <p>Jvaughters: /* Operation */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process is<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image<br /> ** Create the following directory and file<br /> mkdir /tftpboot/tinycore/pxelinlux.cfg<br /> touch /tftpboot/tinycore/pxelinlux.cfg/default<br /> ** Put this text in the default file<br /> default boot/vmlinuz<br /> append initrd=boot/ard-core.gz tftplist=172.1.1.150:/tinycore/cde/onboot_x.lst xvesa=800x600x32<br /> ** Copy PXE boot file<br /> cp /usr/share/syslinux/pxelinux.0 /tftpboot/tinycore/<br /> ** If you cannot find pxelinux.0 file on your system then download syslinux from here:<br /> &lt;nowiki&gt; http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz&lt;/nowiki&gt;<br /> ** you will find pxelinux.0 file in /syslinux-4.06/core/ directory of the archive<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using socat command<br /> * Verify that the /home/scada/scripts/arduino_init script worked with this command<br /> netstat -tl<br /> Expected command ouput:<br /> Active Internet connections (only servers)<br /> Proto Recv-Q Send-Q Local Address Foreign Address State <br /> tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN <br /> tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN <br /> netstat: /proc/net/tcp6: No such file or directory<br /> This shows the port 2111 we are looking for to show that the arduino_init script worked. If you do not see that line, then it did not work.<br /> * Try to manually run socat command: (Note:This resets the program in Arduino after a reconnect to port)<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> If this fails, then check that /dev/arduino_1 exists, it may be a udev naming issue<br /> * Connect to TCP port 2111 from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 172.1.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-04T01:38:03Z <p>Jvaughters: /* Operation */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process is<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image<br /> ** Create the following directory and file<br /> mkdir /tftpboot/tinycore/pxelinlux.cfg<br /> touch /tftpboot/tinycore/pxelinlux.cfg/default<br /> ** Put this text in the default file<br /> default boot/vmlinuz<br /> append initrd=boot/ard-core.gz tftplist=172.1.1.150:/tinycore/cde/onboot_x.lst xvesa=800x600x32<br /> ** Copy PXE boot file<br /> cp /usr/share/syslinux/pxelinux.0 /tftpboot/tinycore/<br /> ** If you cannot find pxelinux.0 file on your system then download syslinux from here:<br /> &lt;nowiki&gt; http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz&lt;/nowiki&gt;<br /> ** you will find pxelinux.0 file in /syslinux-4.06/core/ directory of the archive<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using socat command<br /> * Verify that the /home/scada/scripts/arduino_init script worked with this command<br /> netstat -tl<br /> Expected command ouput:<br /> Active Internet connections (only servers)<br /> Proto Recv-Q Send-Q Local Address Foreign Address State <br /> tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN <br /> tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN <br /> netstat: /proc/net/tcp6: No such file or directory<br /> This shows the port 2111 we are looking for to show that the arduino_init script worked. If you do not see that line, then it did not work.<br /> * Try to manually run socat command: (Note:This resets the program in Arduino after a reconnect to port)<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> If this fails, then check that /dev/arduino_1 exists, it may be a udev naming issue<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-04T01:30:21Z <p>Jvaughters: /* Operation */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process is<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image<br /> ** Create the following directory and file<br /> mkdir /tftpboot/tinycore/pxelinlux.cfg<br /> touch /tftpboot/tinycore/pxelinlux.cfg/default<br /> ** Put this text in the default file<br /> default boot/vmlinuz<br /> append initrd=boot/ard-core.gz tftplist=172.1.1.150:/tinycore/cde/onboot_x.lst xvesa=800x600x32<br /> ** Copy PXE boot file<br /> cp /usr/share/syslinux/pxelinux.0 /tftpboot/tinycore/<br /> ** If you cannot find pxelinux.0 file on your system then download syslinux from here:<br /> &lt;nowiki&gt; http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz&lt;/nowiki&gt;<br /> ** you will find pxelinux.0 file in /syslinux-4.06/core/ directory of the archive<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using socat command<br /> * Verify that the /home/scada/scripts/arduino_init script worked with this command<br /> netstat -tl<br /> Expected command ouput:<br /> Active Internet connections (only servers)<br /> Proto Recv-Q Send-Q Local Address Foreign Address State <br /> tcp 0 0 0.0.0.0:2111 0.0.0.0:* LISTEN <br /> tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN <br /> netstat: /proc/net/tcp6: No such file or directory<br /> This shows the port 2111 we are looking for to show that the arduino_init script worked. If you do not see that line, then it did not work.<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-04T01:07:04Z <p>Jvaughters: /* Operation */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process is<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image<br /> ** Create the following directory and file<br /> mkdir /tftpboot/tinycore/pxelinlux.cfg<br /> touch /tftpboot/tinycore/pxelinlux.cfg/default<br /> ** Put this text in the default file<br /> default boot/vmlinuz<br /> append initrd=boot/ard-core.gz tftplist=172.1.1.150:/tinycore/cde/onboot_x.lst xvesa=800x600x32<br /> ** Copy PXE boot file<br /> cp /usr/share/syslinux/pxelinux.0 /tftpboot/tinycore/<br /> ** If you cannot find pxelinux.0 file on your system then download syslinux from here:<br /> &lt;nowiki&gt; http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz&lt;/nowiki&gt;<br /> ** you will find pxelinux.0 file in /syslinux-4.06/core/ directory of the archive<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> stty -F /dev/arduino_1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-04T00:50:11Z <p>Jvaughters: /* Booting Process */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process is<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image<br /> ** Create the following directory and file<br /> mkdir /tftpboot/tinycore/pxelinlux.cfg<br /> touch /tftpboot/tinycore/pxelinlux.cfg/default<br /> ** Put this text in the default file<br /> default boot/vmlinuz<br /> append initrd=boot/ard-core.gz tftplist=172.1.1.150:/tinycore/cde/onboot_x.lst xvesa=800x600x32<br /> ** Copy PXE boot file<br /> cp /usr/share/syslinux/pxelinux.0 /tftpboot/tinycore/<br /> ** If you cannot find pxelinux.0 file on your system then download syslinux from here:<br /> &lt;nowiki&gt; http://www.kernel.org/pub/linux/utils/boot/syslinux/4.xx/syslinux-4.06.tar.gz&lt;/nowiki&gt;<br /> ** you will find pxelinux.0 file in /syslinux-4.06/core/ directory of the archive<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-03T22:43:55Z <p>Jvaughters: /* PXE Setup */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> The PXE boot process is<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-03T22:41:12Z <p>Jvaughters: /* Booting Process */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** Download the following files:<br /> &lt;pre&gt;<br /> cd /tftpboot/tinycore/cde/optional<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/socat.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/usb-serial-3.0.21-tinycore.tcz<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> <br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-03T22:28:40Z <p>Jvaughters: </p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Make arduino_init executable<br /> chmod 755 /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> ** create this file:<br /> touch /tftpboot/tinycore_dev/core_root/etc/udev/rules.d/98-arduino.rules<br /> ** We need to put the rules of our Arduinos in this file and this is a subject on it's own. Refer to this [http://combustory.com/wiki/index.php/Arduino_Communications_Device_Naming_with_udev udev naming] page<br /> ** Here is an example of what I used<br /> SUBSYSTEMS==&quot;usb&quot;, ATTRS{serial}==&quot;A700618T&quot;, ATTRS{product}==&quot;FT232R USB UART&quot;, ATTRS{idProduct}==&quot;6001&quot;, ATTRS{idVendor}==&quot;0403&quot;, NAME=&quot;arduino_1&quot;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> &lt;pre&gt;<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz.md5.txt<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-03T22:01:04Z <p>Jvaughters: ROOT</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> ** Add these directories<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/scripts<br /> mkdir /tftpboot/tinycore_dev/core_root/home/scada/data<br /> ** create this file<br /> nano /tftpboot/tinycore_dev/core_root/home/scada/scripts/arduino_init<br /> ** Add these lines:<br /> &lt;pre&gt;<br /> #!/bin/bash<br /> # arduino_init - initialization tasks for scada<br /> ### Main script starts here ###<br /> # Store file name of arduino<br /> FILE=&quot;/dev/arduino_1&quot;<br /> <br /> # Arduino Communications<br /> # set serial commuication for arduino<br /> stty -F $FILE cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts<br /> # make sure file (serial device) exist and is readable<br /> if ! pidof socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1; then<br /> echo &quot;$FILE is not logging&quot;<br /> if [ ! -c $FILE ]; then<br /> echo &quot;$FILE : does not exists&quot;<br /> exit 1<br /> elif [ ! -r $FILE ]; then<br /> echo &quot;$FILE: can not read&quot;<br /> exit 2<br /> else<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> echo &quot;start process - socat TCP-LISTEN:2111,fork OPEN:$FILE&quot;<br /> fi<br /> fi<br /> exit 0<br /> &lt;/pre&gt;<br /> ** Edit this file: <br /> nano /tftpboot/tinycore_dev/core_root/opt/bootlocal.sh<br /> ** Add these lines<br /> /etc/init.d/dropbear start<br /> sh /home/scada/scripts/arduino_init &amp;<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftpboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> &lt;pre&gt;<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz.md5.txt<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-03T21:45:07Z <p>Jvaughters: </p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /tftpboot/tinycore/boot/core.gz /tftpboot/tinycore_dev/<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> mkdir /tftpboot/tinycore_dev/core_root<br /> cd /tftpboot/tinycore_dev/core_root<br /> zcat ../core.gz | sudo cpio -i -H newc -d<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> cd /tftboot/tinycore_dev/core_root<br /> sudo find | sudo cpio -o -H newc | gzip -2 &gt; ../ard-core.gz<br /> cd ..<br /> cp ard-core.gz /tftpboot/tinycore/boot/<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> &lt;pre&gt;<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz.md5.txt<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-03T21:28:03Z <p>Jvaughters: </p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount TinyCore-current.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /mnt/tmp/boot/bzImage /mnt/tmp/boot/tinycore.gz /tmp<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> <br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> &lt;pre&gt;<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz.md5.txt<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-11-03T21:17:42Z <p>Jvaughters: </p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso and copy entire contents of the iso to a tftboot directory<br /> &lt;pre&gt;<br /> sudo mkdir /mnt/tmp<br /> sudo mount tinycore.iso /mnt/tmp -o loop,ro<br /> sudo cp -r /mnt/tmp/* /tftpboot/tinycore/<br /> sudo umount /mnt/tmp<br /> &lt;/pre&gt;<br /> * copy core.gz to a development dir<br /> &lt;pre&gt;<br /> sudo cp /mnt/tmp/boot/bzImage /mnt/tmp/boot/tinycore.gz /tmp<br /> &lt;/pre&gt;<br /> * extract core.gz<br /> <br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> &lt;pre&gt;<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz.md5.txt<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * socat example of TCP to serial port - you have to set the serial port with stty - This resets the program in Arduino after a reconnect to port.<br /> socat TCP-LISTEN:2111,fork OPEN:/dev/arduino_1<br /> * Connect to TCP from another computer<br /> rm -f /home/scada/data/arduino_1_in<br /> mkfifo /home/scada/data/arduino_1_in<br /> tail -f /home/scada/data/arduino_1_in | nc 192.168.1.147 2111 &gt; /home/scada/data/arduino_1 &amp;<br /> * Send a command to the pipe into the nc command<br /> echo S &gt; /home/scada/data/arduino_1_in<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-10-29T00:16:21Z <p>Jvaughters: </p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save you money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso<br /> &lt;pre&gt;sudo mkdir /mnt/tmp<br /> sudo mount tinycore.iso /mnt/tmp -o loop,ro<br /> cp /mnt/tmp/boot/bzImage /mnt/tmp/boot/tinycore.gz /tmp<br /> sudo umount /mnt/tmp&lt;/pre&gt;<br /> * copy entire contents of the iso to a tftboot directory<br /> * copy core.gz to a development dir<br /> * extract core.gz<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> &lt;pre&gt;<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz<br /> wget http://distro.ibiblio.org/tinycorelinux/4.x/x86/tcz/dropbear.tcz.md5.txt<br /> &lt;/pre&gt;<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-10-28T20:05:21Z <p>Jvaughters: </p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management, therefore, I may have some references that apply to that subject to use as examples.<br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> If you do not fully understand these topics below, this article will still be helpful for learning the capabilities of computers. Finding out computing techniques is half the battle to finding solutions. You can always learn the skills later and things will eventually fall in place.<br /> <br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> * You understand how to configure booting from HD,USB,CD,PXE<br /> * You understand sudo, su, chroot commands<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save you money or buy one cheap just to help you learn as a low cost education. The hardware requirements are very little, you should be fine as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE or SATA to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==<br /> ===PXE Setup===<br /> ====Development Environment====<br /> * download TinyCore-current.iso<br /> * mount TinyCore-current.iso<br /> * copy entire contents of the iso to a tftboot directory<br /> * copy core.gz to a development dir<br /> * extract core.gz<br /> * modify/add files/dirs in the development dir (use chroot commands for setting passwords and other system level settings)<br /> * pack up the new core and move it to the PXE boot dir (show script for doing this)<br /> ====Booting Process====<br /> * modify PXE boot settings to boot with your new root image.<br /> ** example of default boot properties and file<br /> ** example of how to set up the .lst files to load expansion modules<br /> ** introduce the TinyCore [http://distro.ibiblio.org/tinycorelinux/faq.html#bootcodes boot codes] and provide your example<br /> * log into the booted computer and test/verify the configuration and update image and reboot if needed<br /> ====Operation====<br /> * Create scripts to transfer Arduino to interface with TCP port using nc command<br /> * Create scripts to connect to the port on the Arduino Server and collect data<br /> * Discuss security and ssh <br /> * Discuss file transfer methods<br /> * Discuss cron jobs and set up<br /> * This section will end up being a wide scope with many ideas presented and possibly referenced</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-10-28T17:42:27Z <p>Jvaughters: </p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management. <br /> <br /> This article is not meant to be a step by step procedure, simply because there are many variables in each of our situations. Mainly this is a guide to how to accomplish the task with a conceptual basis that will lead you to discover some solutions that are needed for your application. It is more of a framework with some details and references.<br /> <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> <br /> =Assumptions=<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save you money. The hardware requirements are very little, as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and concept and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE to SD converter, which I have not tried yet, but they look interesting.<br /> <br /> ==Configuration==</div> Jvaughters http://www.combustory.com/wiki/index.php/Arduino_Server Arduino Server 2012-10-28T17:35:54Z <p>Jvaughters: /* Boot Methods */</p> <hr /> <div>=Summary=<br /> In determining a method to create a distributed sensor network I decided to test the idea of taking some old hardware to use it as a remote server to communicate with Arduinos. The basic idea is to have a server that communicates with the Arduinos and sends the data to a central monitoring process over the network. As long as you have a network connection to the server, you can add as many Arduinos as the server can handle to monitor or control whatever it is you are trying to accomplish.The motivation for this investigation revolved around Energy Management. <br /> =Software=<br /> The Arduino Server will be focused on Linux. I guess it is possible to consider windows, but I have not been able to find the same capabilities easily and I am not sure it is even worth investigating, given the ease and flexibility of linux in this application. The central monitoring computers can be any OS that is capable of communicating to network TCP ports or file transfer, which is pretty much anything.<br /> =Assumptions=<br /> * You are familiar with the Linux command line<br /> * You understand basic text file configuration methods<br /> * You are familiar with serial communications in Linux<br /> * You are able to manipulate computer BIOS settings<br /> <br /> =Server=<br /> The idea is that you are able to find any old server that you may have laying around and put it to use and save you money. The hardware requirements are very little, as long as you have about 256k in memory. It may be possible to have less, but that is where I decided to draw the line. The processor is mostly irrelevant, because just about any processor you have laying around will most likely be able to manage the light load we are creating. I will not be testing it, but it may be possible to go as far back as a 386. The hardware configuration that I am using is a 1.2MHz pentium with 256k in memory, which actually works very well even in full GUI mode. You should also be able to find this type of computer laying around in many junk piles at a computer swap.<br /> <br /> ==Operating System==<br /> After a significant search and years of playing around with small linux distributions, I have fallen on upon [http://distro.ibiblio.org/tinycorelinux/ Tiny Core Linux]. It is amazing. With this distribution you can breath life into old computers you thought were long useless. It has a full GUI and is quite capable of many tasks. With a quick download you can be up and running in no time. What really sealed the deal for me was the fact that I could change all the characteristics of this OS with ease and quickly. After fiddling around with many other linux distros for hours or even days, I was making progress with Tiny Core literally in minutes. I'm completely sold on this idea and concept and while many have created small distributions, this concept is masterful in my eyes and far better than any other that I have tried.<br /> <br /> ==Boot Methods==<br /> With Tiny Core you have these boot options: HD,CD,USB,PXE. I am focusing on PXE (Network Booting), because to me this is the best way to manage old computers that tend to die. I can pretty much find any old computer with net boot capability and just plug it in and off we go with very little work. The CD and USB are similar in this capability, but not nearly as fast on booting up. The HD being the least flexible of all options, but may not be too bad if you use an IDE to SD converter, which I have not tried yet, but they look interesting.</div> Jvaughters