tag:blogger.com,1999:blog-36015987407340098502024-03-18T20:03:48.490-07:00AkademiiQuackshttp://www.blogger.com/profile/05943710012093486416noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3601598740734009850.post-75163221234959818922015-02-27T13:41:00.000-08:002015-02-27T13:44:39.626-08:00Cross compiling armhf for Debian distribution (Qt5 and chroot)This guide covers building Qt5 projects into armhf architecture .deb files for distribution.<br />
<div>
<br />
<h2>
Make Emulated Root Enviroment</h2>
</div>
<div>
First we want to make an emulated root environment to do all of our work in [1]. We need to get debootstrap and qemu-user-static to do this.</div>
<div>
<script src="https://gist.github.com/anonymous/e3297582cd817ef16969.js"></script>
<br /></div>
<div>
This will take a long time as we are building a new root filesystem of archetecture armhf in /chroots/sid-armhf. You may have noticed sid in a few places. This is debians unstable distribution. You could replace it with any other release found in:<br />
<a href="ftp://ftp.debian.org/debian/dists/">ftp://ftp.debian.org/debian/dists/</a><br />
<br />
Next we need to change our apparent root directory and mount the proc directory:<br />
<script src="https://gist.github.com/anonymous/c6be22de22de35fd7262.js"></script>
<br />
Create a /usr/sbin/policy-rc.d to prevent daemons from starting up inside the chroot:</div>
<div>
<script src="https://gist.github.com/anonymous/eb29e8917f6c7cf6fd69.js"></script>
<br />
And change the permissions to 775:<br />
<script src="https://gist.github.com/anonymous/8c388fd4dc89cc80b102.js"></script>
<br />
Finally modify the /etc/apt/sources.lst file to a proper repository for the root:<br />
<script src="https://gist.github.com/anonymous/9a450fb636cf6fddb327.js"></script>
Then update and install the archive-keyring followed by another update of apt:<br />
<script src="https://gist.github.com/anonymous/852593a15cba677ac9ad.js"></script>
<br />
To reduce error messages about locales you may wish to install the locales package in the emulated root environment:<br />
<script src="https://gist.github.com/anonymous/df9a826467a0f7bba060.js"></script>
<br />
And then configure it selecting (assuming you are using US English):<br />
en_US.ISO-8859-1<br />
en_US.ISO-8859-15<br />
en_US.UTF-8<br />
I chose to use UTF-8 as the default locale.<br />
<script src="https://gist.github.com/anonymous/96a49f49dd2753c4a45e.js"></script>
<br />
<div>
<h2>
Making a .deb from a Qt Project</h2>
<div>
This next portion focuses on creating a .deb file from a Qt project, following the steps outlined in [3] is recommended for a better understanding.</div>
<br />
I have built a sample project to package which can be found here:<br />
<a href="https://bitbucket.org/ablaylock/qtdebianpackage.git">https://bitbucket.org/ablaylock/qtdebianpackage.git</a><br />
<br />
Clone the repo into helloworld-0.0.1 (do this somewhere smart like /home/username):<br />
<script src="https://gist.github.com/anonymous/5b535531a38ad6493968.js"></script>
<br />
Next we need to install the proper packages for building the Qt project and .deb files:<br />
<script src="https://gist.github.com/anonymous/abdd0689433750bad0e7.js"></script>
<br />
Now we are ready to rock. To build the package (without source, if you want source follow the steps in [3]) run the dist_gen.sh script.<br />
<script src="https://gist.github.com/anonymous/3c30721326bb58681820.js"></script>
<br /></div>
<div>
[1] <a href="https://wiki.debian.org/ArmHardFloatChroot">https://wiki.debian.org/ArmHardFloatChroot</a><br />
[2] <a href="http://ubuntuforums.org/showthread.php?t=1346581">http://ubuntuforums.org/showthread.php?t=1346581</a></div>
<div>
[3] <a href="https://bhavyanshu.me/how-to-make-debian-packages-for-qt-c-based-applications/11/10/2014/">https://bhavyanshu.me/how-to-make-debian-packages-for-qt-c-based-applications/11/10/2014/</a></div>
Quackshttp://www.blogger.com/profile/05943710012093486416noreply@blogger.com0tag:blogger.com,1999:blog-3601598740734009850.post-57672531140554365222013-06-03T14:03:00.000-07:002013-06-03T15:32:04.917-07:00OSX PDEsThis guide was made on an Early 2011 MacBook Pro running 10.8.3 and Xcode 4.6.2<br />
<h3>
What is a PDE?</h3>
A PDE is a <i>Printing Dialog Extension.</i> In other words when one goes to print something and they want the advanced printing options they use a PDE. An example using the TextEdit application and a Brother 2240 printer can be seen in Figures 1 - 3. To initially get to the printing options click the <i>Show Details</i> button on the bottom of the printing dialog shown in Figure 1. From there notice the drop down menu labeled <i>TextEdit</i>. This drop down menu contains all of the printing option panels supported by both the app, the operating system, and the print driver as shown in Figure 2. By selecting the <i>Print Settings</i> item from the drop down the dialog automatically grows to accommodate the settings. This <i>Print Settings</i> dialog is the PDE. <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaT8ePm7XTtVc_54Y010y7fv9SvVw-siZF2VrXWECqVkX8Xwit-JPX58oHXr4TuWpJETzGvotc3ODdnUCYw7QUVCEUUdlZm3TCPjHuD75J5Z2fGJNMmumZI74ewG68ym7lNMKLCZOP0Uc/s1600/Screen+Shot+2013-06-03+at+2.46.55+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="593" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaT8ePm7XTtVc_54Y010y7fv9SvVw-siZF2VrXWECqVkX8Xwit-JPX58oHXr4TuWpJETzGvotc3ODdnUCYw7QUVCEUUdlZm3TCPjHuD75J5Z2fGJNMmumZI74ewG68ym7lNMKLCZOP0Uc/s640/Screen+Shot+2013-06-03+at+2.46.55+PM.png" width="640" /></a></div>
<div class="separator" id="Fig1" style="clear: both; text-align: center;">
Figure 1: Basic Print Dialog
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBRBDqJlTMJKKq-U6S00FpECzy4O49Yq0LuLJKqRs1KXJYGWo4B2xMJYkDgrgwQBqpd_h_poxkvZybQk4TY8F396IEvx7FwDMCrEqIIwD9PZ_VL1CI0BcETQYgUDnVgWK5gl_X3l5XNcA/s1600/Screen+Shot+2013-06-03+at+2.43.58+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBRBDqJlTMJKKq-U6S00FpECzy4O49Yq0LuLJKqRs1KXJYGWo4B2xMJYkDgrgwQBqpd_h_poxkvZybQk4TY8F396IEvx7FwDMCrEqIIwD9PZ_VL1CI0BcETQYgUDnVgWK5gl_X3l5XNcA/s1600/Screen+Shot+2013-06-03+at+2.43.58+PM.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 2: Print Settings Options</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsTBMD7TPw17MrUr76BdPYNurWG7zrZRkDxoeqB-WE2ul5-p8PIiI0PjqzbXPiyvds-qmhe1of3IjjFQA3yEqGtm_0szS5r7KjSIwWSCCjcexJzPDrciMCOZCCCpWk8N4Pm6lscghuGKk/s1600/Screen+Shot+2013-06-03+at+2.44.13+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="545" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsTBMD7TPw17MrUr76BdPYNurWG7zrZRkDxoeqB-WE2ul5-p8PIiI0PjqzbXPiyvds-qmhe1of3IjjFQA3yEqGtm_0szS5r7KjSIwWSCCjcexJzPDrciMCOZCCCpWk8N4Pm6lscghuGKk/s640/Screen+Shot+2013-06-03+at+2.44.13+PM.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 3: Full Print Dialog</div>
<h3>
Who Cares About PDEs?</h3>
<div>
It turns out not many people. The major group who cares are printer manufacturers. The occasional sucker cares too. Why sucker and not something less derogatory? The documentation on PDEs and the whole of CUPS is total junk. Why care about PDEs? As a printer manufacturer or sucker one might develop a printer of some sort which has more options than just the number of copies and the paper size among a small handful of others. </div>
<div>
<br /></div>
<h3>
PDE Nitty-Gritties</h3>
<h4>
Documentation</h4>
<div>
So the first thing that is informative in developing PDEs is to have all of the relevant (but bad) documentation available. The following list has been conceivably helpful:</div>
<div>
<ul>
<li>http://www.cups.org/index.php - Contains documentation on the CUPS printing system.</li>
<li>http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Printing/osxp_aboutprinting/osxp_aboutprt.html - An overview of printing in OSX, pretty useless because it is written for an app developer.</li>
<li>http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf - The PPD specification. PPDs will be discussed a little later but are very important.</li>
<li>http://partners.adobe.com/public/developer/en/ps/5645.PPD_Update.pdf - An update to the PPD specification.</li>
<li>http://developer.apple.com/legacy/library/documentation/Printing/Conceptual/ExtPrintingDialogs/ExtPrintingDialogs.pdf - A legacy document from Apple which has not been updated. :(</li>
<li>http://developer.apple.com/legacy/library/documentation/Printing/Reference/PrintingPlugin_Ref/ppiref.pdf - Another legacy document that fits with the aforementioned document.</li>
</ul>
<div>
There are probably more but I have forgotten them.</div>
</div>
<h4>
PPDs</h4>
<div>
A PPD is a <i>PostScript Printer Description</i> file. To my understanding it tells CUPS about your printer. A PDE exposes the features defined within a PPD. PPDs also include some localization info so that the print driver options may be localized based on the operating systems language settings.</div>
<h4>
Making a PDE</h4>
<div>
Apple is generous enough to provide the OutputBinsPDE example which does not show up when you search online (at least not Google). You may find it by searching for <i>OutputBinsPDE</i> in the documentation or you can find it manually under Mac OS X 10.6 Core Library/Graphics & Animation/Printing/OutputBinsPDE (assuming it exists there once 10.9 hits the streets). Go ahead and click the open project button.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpsAYU47xa_hITQJdRsjjwbQfXry6xJP_bjG22o2kUQpP1FbWLjyohyxcWH4cY1lyJYUW-X0b59_7qcj-7EIU-WaoQKaCw1b6YyrFNPPkXsjQdHXQpw_LqLnpNa-wspVUjAI1-EXcH9j0/s1600/Screen+Shot+2013-06-03+at+3.38.07+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="467" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpsAYU47xa_hITQJdRsjjwbQfXry6xJP_bjG22o2kUQpP1FbWLjyohyxcWH4cY1lyJYUW-X0b59_7qcj-7EIU-WaoQKaCw1b6YyrFNPPkXsjQdHXQpw_LqLnpNa-wspVUjAI1-EXcH9j0/s640/Screen+Shot+2013-06-03+at+3.38.07+PM.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 4: Xcode Documentation</div>
<div class="separator" style="clear: both; text-align: left;">
It will automatically download (I think?) the project. Go ahead and click Run. Okay it built (with some warnings), now lets install it. </div>
<h4>
Installing the PDE</h4>
<div class="separator" style="clear: both; text-align: left;">
To install PDEs and PPDs navigate to: /Library/Printers/. The following steps may need authentication which is okay. Make a folder in /Library/Printers called Sample and dump the bundle you just compiled into the Sample folder. By default the downloaded example project will be placed in the Downloads folder. Next, the PPD needs to be installed. To install a PPD it first needs to be archived into a .gz folder. This may be done by first duplicating the PPD file. Rename the file to not have an extension i.e. <i>OutputBinsPDETest</i>. Open the terminal and navigate to downloaded project (cd ~/Downloads/OutputBinsPDE) and type <i>gzip </i><i>OutputBinsPDETest</i>. Hit enter and notice that we now have a file named <i>OutputBinsPDETest.gz</i>. This file should be moved into the /Library/Printers/PPDs/Contents/Resources folder. Once this is complete we can now install a printer that uses this PPD/PDE combo by opening the <i>System Preferences</i>. At the add printer dialog click on the IP sub dialog. In the address go ahead and type <i>localhost:55000</i> and select <i>HP Jetdirect</i> for the protocol. Leave the Queue field empty. See Figure 5 for a picture of the settings.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAfS-8ahIvzn4NG7sh4bkmR94Uqw2dSVucpTMqycznWVd0PPG7stqElzqrb3D6Ewty1JlAz9BEow98r0RDfAda7Az_2ePQjLFKWwfc6O8HBnOwC6uTgJPE3k2pbqDGjha1SB61xJ_pPZM/s1600/Screen+Shot+2013-06-03+at+3.58.22+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="352" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAfS-8ahIvzn4NG7sh4bkmR94Uqw2dSVucpTMqycznWVd0PPG7stqElzqrb3D6Ewty1JlAz9BEow98r0RDfAda7Az_2ePQjLFKWwfc6O8HBnOwC6uTgJPE3k2pbqDGjha1SB61xJ_pPZM/s400/Screen+Shot+2013-06-03+at+3.58.22+PM.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 5: Printer Configuration 1</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Give the printer a name and under the <i>Use</i> menu select <i>Select Printer Software</i>, Figure 6. In the Filter type <i>Bin</i> and select <i>Postscript Printer Manufacturer OutputBins PDE test</i>. If a message such as the one shown in Figure 7 pops up, click <i>Continue</i>. Another dialog may pop up as shown in Figure 8, press <i>Repair</i> and wait because it may take a while. </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9b2h6wg9t8jcHAujN7lB4imgc_l-6Vw1pA1p6WJPzrrbF2Xv2xw4hN39I6UCCkE8g_JBpnP1RoKh863nmukjGMJbFi4upUpKoJUTka_vFU0rfpMabXvXzR0aiy2wlC0RhQMzJ2fC5N2g/s1600/Screen+Shot+2013-06-03+at+3.58.40+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9b2h6wg9t8jcHAujN7lB4imgc_l-6Vw1pA1p6WJPzrrbF2Xv2xw4hN39I6UCCkE8g_JBpnP1RoKh863nmukjGMJbFi4upUpKoJUTka_vFU0rfpMabXvXzR0aiy2wlC0RhQMzJ2fC5N2g/s320/Screen+Shot+2013-06-03+at+3.58.40+PM.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 6: Printer Software Selection</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD_P4aW2p3EPbkiEqwQgMOlEm4qn_PXPdI2Tq4tBf9L7jB6S09W96BTZKT8pDznT2O5sA_KBAIVn7DmDpLJZWg2MB8zX36iqkth2jCd7CTEzpXfAmSefahTgp71u95W8mhSvjTQuJKwaE/s1600/Screen+Shot+2013-06-03+at+4.19.35+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhD_P4aW2p3EPbkiEqwQgMOlEm4qn_PXPdI2Tq4tBf9L7jB6S09W96BTZKT8pDznT2O5sA_KBAIVn7DmDpLJZWg2MB8zX36iqkth2jCd7CTEzpXfAmSefahTgp71u95W8mhSvjTQuJKwaE/s320/Screen+Shot+2013-06-03+at+4.19.35+PM.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 7: Printer Software Configuration Warning 1</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjecs-55-AXcb6GYdBgLEpQ8U81VOm9AKa3pVN5E0pkByC8zVc-7vSoFd3ulgo6K3GeBJAM5y3pz-loBefD5GL-oOBE6qRKjuWHW1au-AQVmm_cPGoOu54fkZ1OmarNKzFrYCcg2bn5Dmc/s1600/Screen+Shot+2013-06-03+at+4.19.41+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjecs-55-AXcb6GYdBgLEpQ8U81VOm9AKa3pVN5E0pkByC8zVc-7vSoFd3ulgo6K3GeBJAM5y3pz-loBefD5GL-oOBE6qRKjuWHW1au-AQVmm_cPGoOu54fkZ1OmarNKzFrYCcg2bn5Dmc/s320/Screen+Shot+2013-06-03+at+4.19.41+PM.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 8: Printer Software Configuration Warning 2</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h4>
Testing the PDE</h4>
<div class="separator" style="clear: both; text-align: left;">
Now we have the printer installed. Open TextEdit and print anything. Try to get to the advanced settings menu we just made, Figure 9. Oh no, the PDE is unsupported because it does not have a version for the current architecture Figure 10. Darn. </div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHSkfzl1QAZLkfCqHSeTJvYKh9H6wDjt7zZLtwqQ8XHZkE3BnTkUpYOA5OEYTy97lFFPUaDwx6GhtkgZ80lmtdjo9z2J5Lc581VCHkcj10O8X5ip-TX4Nus4YenuPPlngnZlCdgnbyEBE/s1600/Screen+Shot+2013-06-03+at+4.07.06+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHSkfzl1QAZLkfCqHSeTJvYKh9H6wDjt7zZLtwqQ8XHZkE3BnTkUpYOA5OEYTy97lFFPUaDwx6GhtkgZ80lmtdjo9z2J5Lc581VCHkcj10O8X5ip-TX4Nus4YenuPPlngnZlCdgnbyEBE/s1600/Screen+Shot+2013-06-03+at+4.07.06+PM.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 9: Advanced Printer Settings</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7Q15Ox-5rwv2mM_-W40AsGh45UlgZp395zWDBYcW9hHSefke_A-XVzpA62XytZV_oGGfOlk1EfRSGOMVmbGqFzs-vQMaxowmToa6sunYFuWsZ3VLI8gdy4rgNNAD6BpPUGrpddl3l9nc/s1600/Screen+Shot+2013-06-03+at+4.07.11+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7Q15Ox-5rwv2mM_-W40AsGh45UlgZp395zWDBYcW9hHSefke_A-XVzpA62XytZV_oGGfOlk1EfRSGOMVmbGqFzs-vQMaxowmToa6sunYFuWsZ3VLI8gdy4rgNNAD6BpPUGrpddl3l9nc/s320/Screen+Shot+2013-06-03+at+4.07.11+PM.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 10: Unsupported PDE due to Architecture </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Go back to Xcode and go to the <i>Build Settings</i>, Figure 11. Change the Debug Architecture to <i>Native Architecture of the Build Machine</i>. This allows the PDE to be build for an x86_64 architecture. For a PDE to work it must match the architecture of the application which launched the print dialog. This become super hairy because some apps are build for i386 and some for x86_64, and if you are <i>really</i> unlucky one of the Power PC architectures. Keep that in mind if the PDE you develop is to be deployed. So now recompile and reinstall the PDE. You do not need to redo the part with the .gz file. To ensure the effects take hold quit TextEdit and force kill the <i>printtool</i> process in Activity Monitor. Now reprint something from TextEdit and try and navigate to the <i>Output Bins</i> menu, Figure 12 and 13. Cool, you now have a PDE.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAdBWlYcuvhOBMsGv85oLzoXWr8wK8b9el2S778s5KajX4BdDibMvt1LkNUhOxy1c_BRKnL8AcrrFa5zKILrliIwn-zewcUnMLEfv4_eUzfpm1Zk_doKP8nrljIxiYrZzwO9VMSx9uT10/s1600/Screen+Shot+2013-06-03+at+4.28.37+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="450" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAdBWlYcuvhOBMsGv85oLzoXWr8wK8b9el2S778s5KajX4BdDibMvt1LkNUhOxy1c_BRKnL8AcrrFa5zKILrliIwn-zewcUnMLEfv4_eUzfpm1Zk_doKP8nrljIxiYrZzwO9VMSx9uT10/s640/Screen+Shot+2013-06-03+at+4.28.37+PM.png" width="640" /></a></div>
<div class="" style="clear: both; text-align: center;">
Figure 11: Xcode Architectures Settings</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdxw3_n4xrQXXy59SaGTA_LfZJsp1doByBCgSehe-CYI9maY1d4c0BgP-bDMMRNnweiamg28odC_Sxnhaur3_1MB01uo4ZjFO-lvzhHxC3qCcWyd_rvR2MTn6IZ7qwUqN8jWFfiYTNegs/s1600/Screen+Shot+2013-06-03+at+4.20.54+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdxw3_n4xrQXXy59SaGTA_LfZJsp1doByBCgSehe-CYI9maY1d4c0BgP-bDMMRNnweiamg28odC_Sxnhaur3_1MB01uo4ZjFO-lvzhHxC3qCcWyd_rvR2MTn6IZ7qwUqN8jWFfiYTNegs/s1600/Screen+Shot+2013-06-03+at+4.20.54+PM.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Figure 12: Advanced Printer Settings</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8jqjtH2xvVkL0BOc2e7jBgRKADCKPWAylX_tQdZ-7geIg84sVV3nY7yXyqsJq4eNlwGXkQkdracsd8LgT9fWjnHIADwJg-Nb2c32Ayy0YBwSSgDavobkKM3okZQFxQ5soNH0DiN23Wfg/s1600/Screen+Shot+2013-06-03+at+4.20.47+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8jqjtH2xvVkL0BOc2e7jBgRKADCKPWAylX_tQdZ-7geIg84sVV3nY7yXyqsJq4eNlwGXkQkdracsd8LgT9fWjnHIADwJg-Nb2c32Ayy0YBwSSgDavobkKM3okZQFxQ5soNH0DiN23Wfg/s400/Screen+Shot+2013-06-03+at+4.20.47+PM.png" width="400" /></a></div>
<div class="" style="clear: both; text-align: center;">
Figure 13: Advanced Printer Settings Panel</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
</div>
Quackshttp://www.blogger.com/profile/05943710012093486416noreply@blogger.com0tag:blogger.com,1999:blog-3601598740734009850.post-4849176959460455412012-02-16T11:55:00.000-08:002012-03-18T17:57:45.473-07:00BeagleBone GPIO TestingBeing completely new to embedded Linux and having only read how to use GPIO on other platforms I was quite pleased to finally get something working.<br />
<br />
<br />
The script found <a href="http://blog.makezine.com/archive/2009/02/blinking-leds-with-the-beagle-board.html">here</a> (1) was my starting place. The script seems extremely strait forward however I found myself struggling to figure out which GPIO # corresponded with which pin on the Beaglebone. Looking through the system reference manual for the BeagleBone and comparing it to the TI reference manual ended up confusing the issue. Basically the GPIO # corresponds to (32*First # + Second #) of a pin designation. To make this less confusing lets look at a couple of examples. First what is the pin number of GPIO0_15? Pluggin into the formula we get (32*0+15) therefore the pin number must be 15. How about one that is in the second GPIO bank, say GPIO2_23? Again, using the formula we get (32*2+23) which equals 87.<br />
<br />
Another issue was TI reference manual states that the default mux setting for a pin corresponds to the pin name. So then I look at the BeagleBone manual and, for example, it says pin 25 on header J8 is GPIO1_0 you would think, Okay cool! I can export GPIO 32 (using the aforementioned formula) and blink an LED. Now if you try this without doing anything first you will end up with a LED that is dimly lit (at least that is what happened in my case, I am guessing a weak pull-up caused this behavior).<br />
<br />
What could be wrong? Well it turns out whoever wrote the BeagleBone SRM (system reference manual) decided that it would be awesome to rename all of the pins randomly to one of their many muxable outputs. Great.<br />
<br />
How do we make it so we can we change these mux settings? First, we must first figure out what the acutal name of the pin is. This can be done by looking at what the primary mode of the pin is. In the case of pin 25 on header J8 we see that MODE0 is gpmc_ad0. Now that we have this information we can properly change the mux mode and other pin setting.<br />
<span style="font-size: x-small;"><br />
</span><br />
<i><span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><span style="background-color: white;">"</span><span style="background-color: white;">The /sys/kernel/debug/omap_mux filenames are taken from the Mode 0</span><span style="background-color: white;"> </span></span></i><br />
<span style="background-color: white; font-family: 'Courier New', Courier, monospace; font-size: x-small; font-style: italic;">usages of the pins, regardless of which mode the pin mux is currently </span><br />
<span style="background-color: white;"><span style="font-family: 'Courier New', Courier, monospace; font-size: x-small; font-style: italic;">in." </span><span style="font-family: inherit;"><a href="https://groups.google.com/group/beagleboard/browse_thread/thread/6cf4d3c829709f7e/d098d5bc15dbc658?lnk=gst&q=0x44e10950#d098d5bc15dbc658" target="_blank">- Found here</a> (2)</span></span><br />
<div>
<span style="background-color: white;"><br />
</span></div>
<div>
<span style="background-color: white;">Ok so if we want pin 25 on header J8 to <i>actually</i><b style="font-style: italic;"> </b>be muxed to GPIO1_0 that means we need to set the mode to 7 (as per the BeagleBone SRM).</span></div>
<div>
<br /></div>
<div>
This command ought to do nicely:</div>
<div>
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">echo 7 > /sys/kernel/debug/omap_mux/gpmc_ad0</span></div>
<div>
To check an make sure the change was made properly you can run this:</div>
<div>
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">cat /sys/kernel/debug/omap_mux/gpmc_ad0</span></div>
<div>
which, if the pin was set correctly, should have this:</div>
<div>
<span style="background-color: white;"><span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE7</span></span></div>
<div>
as part of the output.<br />
<br /></div>
<div>
Sweet, we can now write something to toggle GPIO1_0 on pin 25 of header J8.</div>
<div>
<br /></div>
<div>
To recap here is what needs to be done in shell commands:</div>
<div>
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">#Make sure the pin is in the right mode.</span></div>
<div>
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">cat /sys/kernel/debug/omap_mux/gpmc_ad0</span></div>
<div>
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">#If the mode returned by this command is not mux_mode7 set it.</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">echo 7 > /sys/kernel/debug/omap_mux/gpmc_ad0</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">#Okay now the pin is ready to be used</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">#Export the pin</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">echo 32 > /sys/class/gpio/export</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">#Turn the pin on</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">echo "high" > /sys/class/gpio/gpio32/direction</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">#Turn pin off</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">echo "low" > /sys/class/gpio/gpio32/direction</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">#Unexport the pin</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">echo 32 > /sys/class/gpio/unexport</span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br />
</span><br />
<span style="font-family: inherit;">Finally I want to leave links to the resources I used to figure this out.</span><br />
(1) http://blog.makezine.com/2009/02/03/blinking-leds-with-the-beagle-board/<br />
(2) https://groups.google.com/forum/?fromgroups#!topic/beagleboard/bPTTyClwn34<br />
(3) http://beagleboard.org/static/beaglebone/a3/Docs/Hardware/BONE_SRM.pdf<br />
(4) http://www.ti.com/product/am3359<br />
For (4) I used both the Technical Reference Man<span style="font-family: inherit;">ual and the <span style="line-height: 15px;">AM335x ARM Cortex-A8 Microprocessors data sheets.</span></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><br />
</span></div>Quackshttp://www.blogger.com/profile/05943710012093486416noreply@blogger.com5