<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://ift.wiki.uib.no/index.php?action=history&amp;feed=atom&amp;title=JTAG</id>
	<title>JTAG - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://ift.wiki.uib.no/index.php?action=history&amp;feed=atom&amp;title=JTAG"/>
	<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=JTAG&amp;action=history"/>
	<updated>2026-04-05T10:24:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=JTAG&amp;diff=1602&amp;oldid=prev</id>
		<title>Nfyku: Created page with &#039;== notes == Sysfs exports information about devices and drivers from the kernel device model to userspace. Gpio-sysfs is the prefered method for accessing gpio from userspace. It…&#039;</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=JTAG&amp;diff=1602&amp;oldid=prev"/>
		<updated>2011-06-22T12:59:54Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;== notes == Sysfs exports information about devices and drivers from the kernel device model to userspace. Gpio-sysfs is the prefered method for accessing gpio from userspace. It…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== notes ==&lt;br /&gt;
Sysfs exports information about devices and drivers from the kernel device model to userspace.&lt;br /&gt;
Gpio-sysfs is the prefered method for accessing gpio from userspace. It deals with one pin at a time and works in means of reading and writing to files for control.&lt;br /&gt;
&lt;br /&gt;
The control files for each gpio chip is contained within &amp;#039;/sys/class/gpio/&amp;#039;&lt;br /&gt;
 ~ # ls /sys/class/gpio/&lt;br /&gt;
 export       gpiochip231  gpiochip235  gpiochip240  gpiochip248  unexport&lt;br /&gt;
To begin with there is only two files &amp;#039;export&amp;#039; and &amp;#039;unexport&amp;#039; and a folder for each gpio, each gpio has an ID number.&lt;br /&gt;
&lt;br /&gt;
In each folder there are files that contains information about the chip:&lt;br /&gt;
 ~ # ls /sys/class/gpio/gpiochip231/&lt;br /&gt;
 base       label      ngpio      subsystem  uevent&lt;br /&gt;
*&amp;#039;base&amp;#039; contains the ID of the chip, i.e. for gpiochip231, the ID is 231&lt;br /&gt;
 ~ # cat /sys/class/gpio/gpiochip231/base&lt;br /&gt;
 231&lt;br /&gt;
*&amp;#039;label&amp;#039; contains the address (so that you are able to identify which gpio you are dealing with)&lt;br /&gt;
 ~ # cat /sys/class/gpio/gpiochip231/label&lt;br /&gt;
 /plb@0/gpio@81400000&lt;br /&gt;
*&amp;#039;ngpio&amp;#039; contains the number of gpio pins available&lt;br /&gt;
&lt;br /&gt;
In order to get access to a GPIO pin it is necessary to export it using the export file:&lt;br /&gt;
 echo NN &amp;gt; /sys/class/gpio/export&lt;br /&gt;
Where NN is the base of the GPIO chip plus the pin number, i.e. for pin0 of gpiochip231 NN=231, for pin1 NN=232, etc.&lt;br /&gt;
&lt;br /&gt;
An example:&lt;br /&gt;
 echo 231 &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo 232 &amp;gt; /sys/class/gpio/export&lt;br /&gt;
This gives access to pin0 and pin1.&lt;br /&gt;
&lt;br /&gt;
When a pin is exported, a folder is created: &amp;#039;/sys/class/gpio/gpioNN&amp;#039;. Within such a folder you have the control files for the pin, &amp;#039;direction&amp;#039; and &amp;#039;value&amp;#039;&lt;br /&gt;
 ~ # ls /sys/class/gpio/gpio231/&lt;br /&gt;
 direction  subsystem  uevent     value&lt;br /&gt;
&lt;br /&gt;
Example, setting direction of pin0 as output:&lt;br /&gt;
 echo out &amp;gt; /sys/class/gpio/gpio231/direction&lt;br /&gt;
Possible commands for direction:&lt;br /&gt;
 high	 Set GPIO to an output with a starting value of 1&lt;br /&gt;
 low	 Set GPIO to an output with a starting value of 0&lt;br /&gt;
 out	 Same as low&lt;br /&gt;
 in	 Set GPIO to an input&lt;br /&gt;
&lt;br /&gt;
Example, setting value of a pin0 to 1, then reading the value:&lt;br /&gt;
 echo 1 &amp;gt; /sys/class/gpio/gpio231/value&lt;br /&gt;
 cat /sys/class/gpio/gpio231/value&lt;br /&gt;
 1&lt;br /&gt;
&lt;br /&gt;
Current design:&lt;br /&gt;
 sig    phys    NN&lt;br /&gt;
 TDI -&amp;gt; pin6 -&amp;gt; 231&lt;br /&gt;
 TMS -&amp;gt; pin4 -&amp;gt; 232&lt;br /&gt;
 TDO -&amp;gt; pin3 -&amp;gt; 233 &lt;br /&gt;
 TCK -&amp;gt; pin1 -&amp;gt; 234&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
*[http://www.labbookpages.co.uk/electronics/avrs/toolChain.html AVR Hex to SVF]&lt;br /&gt;
*[http://dangerousprototypes.com/tag/xsvf-player/ XSVF stuff to look in to]&lt;br /&gt;
*[http://dangerousprototypes.com/docs/Bus_Pirate Bus pirate]&lt;br /&gt;
*[http://code.google.com/p/the-bus-pirate/updates/list some bus pirate files]&lt;br /&gt;
*[http://code.google.com/p/the-bus-pirate/downloads/detail?name=BPv3.XSVFplayer.v1.1.zip Bus pirate xvsf player stuff]&lt;br /&gt;
*[http://www2.embedded-projects.net/index.php?page_id=221 Even some more about xsvf]&lt;br /&gt;
*[http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;t=57510&amp;amp;highlight=spi+ngw100]&lt;br /&gt;
*[https://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:simple-gpio]&lt;br /&gt;
*[http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO]&lt;br /&gt;
*[http://xilinx.eefocus.com/wall/index.php?act=read&amp;amp;id=1605]&lt;br /&gt;
*[http://hackaday.com/2008/12/01/bus-pirate-firmware-update-v0c-jtag-and-more/]&lt;br /&gt;
*[http://www.avrfreaks.net/wiki/index.php/Documentation:NGW/Newbie/Detailed_IO_Tutorial]&lt;br /&gt;
&lt;br /&gt;
[[Category:Embedded]]&lt;/div&gt;</summary>
		<author><name>Nfyku</name></author>
	</entry>
</feed>