Difference between revisions of "Minnowboard:Toggling LED"

From eLinux.org
Jump to: navigation, search
m (Booting Angstrom)
m (Added back home button)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:Mlogo.png|right|295px|Minnow]]
+
{{Template:Minnowboard_home}}
 +
[[File:Mlogo.png|right|130px|Minnow]]
 
=Summary=
 
=Summary=
  
 
In this guide, we will toggle a user LED on the MinnowBoard step-by-step. This guide is for beginners who are just getting started with the MinnowBoard.  
 
In this guide, we will toggle a user LED on the MinnowBoard step-by-step. This guide is for beginners who are just getting started with the MinnowBoard.  
  
=Contents of the box=
+
=Getting Started=
 
+
For information on 'Setting up a microSD card', 'Booting Angstrom' etc, please refer [http://elinux.org/Minnowboard:Basics here]
When you purchase a MinnowBoard, the following items are included in the box as shown in Figure -1:
 
 
 
#MinnowBoard
 
#5V Power Adaptor
 
#4GB micro SD card preloaded with Angstrom Linux Distribution(Yocto Project Compatible)
 
#USB Cable
 
 
 
 
 
[[File:Mboxcontents.png|center|900px|Figure-1: Box Contents]]
 
 
 
=Anatomy of a MinnowBoard=
 
 
 
==Top Side==
 
This section outlines the various components on the MinnowBoard. Figure -2 below annotates the important components on the top side of the MinnowBoard.
 
 
 
[[File:Minnowboard_front_specs.png|center|1000x1200px|Figure-2: MinnowBoard Top Side]]
 
 
 
Below is a brief description of the micro USB and debugger ports which are annotated in Figure -2.
 
 
 
• Micro USB: This port can be used to access the contents of the MinnowBoard's microSD card as a removable drive on your desktop computer. Simply boot the MinnowBoard up and connect it to your desktop computer using a micro-USB cable.
 
 
 
• Debugger: This mini-USB port allows you to interact with the serial console of the MinnowBoard, so you can log into it and view debugging messages even when an external monitor and keyboard are not connected to the MinnowBoard. You need to use a terminal emulator on your desktop computer to access the serial console at a baud rate of 115200. This is demonstrated later in this guide in the Booting Angstrom section.
 
 
 
==Bottom Side==
 
Figure -3 below annotates the important components on the bottom side of the MinnowBoard.
 
 
 
[[File:Minnowboard_back_specs.png|center|1000x1200px|Figure-3: MinnowBoard Bottom Side]]
 
 
 
=Specifications=
 
 
 
For detailed specifications of the MinnowBoard, please visit our website below:
 
 
 
http://www.minnowboard.org/technical-features/
 
 
 
=Preparing the MicroSD Card=
 
 
 
Please note that this section is completely optional. The MinnowBoard already comes with a microSD card that is preloaded with a working Angstrom Linux image. In case you want to use a newer image or want to program the microSD from scratch, this section covers it all. These steps were created using an Ubuntu 12.10 64-bit system.
 
 
 
''Note:- This section is for Linux users only. If you are using Windows, please skip to the [[#Windows Users|Windows Section]]. If you are using Mac, please skip to the [[#Mac Users|OS X section]].''
 
 
 
'''Step-1:'''
 
 
 
First download the latest Angstrom Linux image for MinnowBoard using the following link:
 
 
 
[http://dominion.thruhere.net/koen/angstrom/minnow/production-Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img.xz Latest Angstrom Image for the MinnowBoard]
 
 
 
At the time of writing this guide, the latest image available for download was 'Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img.xz'
 
 
 
'''Step-2:'''
 
 
 
Insert the microSD card into a microSD compatible writer in your desktop computer. Now, identify the disk device filename for your microSD card. You can do this by opening the Disk Utility application (sometimes also called Disks) in Ubuntu and clicking on the microSD card entry. See the Device field to determine the raw device name of your microSD card. Note that this device name should specify an entire disk device (e.g, /dev/sde), and not an individual disk partition (e.g, /dev/sde1)
 
 
 
'''Step-3:'''
 
 
 
Now, make sure all possible disk partitions from the microSD card are unmounted by typing the command below into your terminal:
 
 
 
$ sudo umount /dev/sdX?*
 
 
 
Here 'sdX' stands for the raw device id of the microSD card.
 
 
 
'''Step-4:'''
 
 
 
Now unpack the image to the microSD card by typing the command below in a terminal window:
 
 
 
$ xzcat Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img.xz | sudo dd of=/dev/sdX
 
  
 
=User LED on the MinnowBoard=
 
=User LED on the MinnowBoard=
  
There are a total of five LED(s) on the MinnowBoard - D11, D12, D13, D14, D15 as shown in Figure -4. Their functions have been listed in the table below:
+
There are a total of five LED(s) on the MinnowBoard - D11, D12, D13, D14, D15 as shown in Figure -1. Their functions have been listed in the table below:
  
  
[[File:Userled.png|600x1000px|Figure-4: LED(s) on the MinnowBoard]]
+
[[File:Userled.png|600x1000px|Figure-1: LED(s) on the MinnowBoard]]
  
  
Line 123: Line 59:
 
=Extra Credit=
 
=Extra Credit=
  
This is an optional section which you can read for further understanding. In a nutshell, we are trying to access the on board USER LED(s) via [http://elinux.org/images/4/4f/02-linux-quick-start.pdf userspace] in Linux. To be more precise we are using the [http://www.makelinux.net/books/lkd2/ch17lev1sec8 sysfs interface]. sysfs is a virtual filesystem which translates the hardware devices and busses attached to the system(board in our case) into a file system hierarchy that can be accessed from userspace. sysfs is generated by the kernel and always mounted at /sys. As discussed earlier, trigger for D11 and D12 LEDs has to be changed to make them function as USER LEDs. I would describe 'trigger' as the API used to link a LED to an 'event' in kernel space. Here, 'event' could be microSD card or Ethernet activity, heartbeat, power etc. To understand this better, take LED D11 for example. The trigger for D11 has been set by default to heartbeat. So, to use it as an USER LED, we have to change the trigger for it to 'none' as shown in Figure - 5 below:
+
This is an optional section which you can read for further understanding. In a nutshell, we are trying to access the on board USER LED(s) via [http://elinux.org/images/4/4f/02-linux-quick-start.pdf userspace] in Linux. To be more precise we are using the [http://www.makelinux.net/books/lkd2/ch17lev1sec8 sysfs interface]. sysfs is a virtual filesystem which translates the hardware devices and busses attached to the system(board in our case) into a file system hierarchy that can be accessed from userspace. sysfs is generated by the kernel and always mounted at /sys. As discussed earlier, trigger for D11 and D12 LEDs has to be changed to make them function as USER LEDs. I would describe 'trigger' as the API used to link a LED to an 'event' in kernel space. Here, 'event' could be microSD card or Ethernet activity, heartbeat, power etc. To understand this better, take LED D11 for example. The trigger for D11 has been set by default to heartbeat. So, to use it as an USER LED, we have to change the trigger for it to 'none' as shown in Figure - 2 below:
 
 
 
 
[[File:Mledtrigger.png|600x1000px|Figure-5: Change LED Trigger]]
 
 
 
 
 
=Booting Angstrom=
 
 
 
'''Step-1:'''
 
 
 
First insert the card into the microSD card slot label side up as shown in Figure -6. Push the microSD card into the slot until it clicks into place.
 
 
 
[[File:Msdcard.png|600px|Figure-6: Connecting the micro SD card]]
 
 
 
 
 
'''Step-2:'''
 
 
 
Next, connect an external keyboard and mouse to the MinnowBoard. Then connect a USB mini cable to your computer and the MinnowBoard as shown in Figure -7. This connection will be used to access the serial console of the MinnowBoard.
 
 
 
[[File:Musb.png|600px|Figure-7: Connecting a USB mini cable for serial console access]]
 
 
 
 
 
'''Step-3:'''
 
 
 
Now power up the MinnowBoard, connect the 5V/2.5A power supply to it as shown in Figure -8:
 
 
 
[[File:Mpower.png|600px|Figure-8: Powering up the MinnowBoard]]
 
 
 
 
 
'''Step-4:'''
 
 
 
Access the MinnowBoard's serial console via a terminal emulator:
 
 
 
$ sudo screen /dev/ttyUSB0 115200
 
 
 
''Note:- You can also use minicom, but screen is much easier to use! Also in most cases the virtual USB serial port is ttyUSB0. If it does not work, try ttyUSB1''
 
 
 
  
'''Step-5:'''
 
  
You should see a similar Angstrom login screen as shown in Figure - 9. The username is 'root' and there is no password - just press the Enter key.
+
[[File:Mledtrigger.png|600x1000px|Figure-2: Change LED Trigger]]
  
[[File:Mangstrom_login.png|600px|Figure-9: Angstrom]]
 
  
 
=Steps=
 
=Steps=
Line 179: Line 77:
 
'''Step-2:'''  
 
'''Step-2:'''  
  
Now we are ready to toggle the LED. Type the following commands in your terminal as shown in Figure - 10(First one is for turning ON and latter for OFF):
+
Now we are ready to toggle the LED. Type the following commands in your terminal as shown in Figure - 3(First one is for turning ON and latter for OFF):
  
 
  echo 1 > /sys/class/leds/minnow_led0/brightness
 
  echo 1 > /sys/class/leds/minnow_led0/brightness
Line 185: Line 83:
  
  
[[File:Mledtrigger.png|600px|Figure-10: Toggle the LED]]
+
[[File:Mledtrigger.png|600px|Figure-3: Toggle the LED]]
  
  
Line 193: Line 91:
  
  
[[File:Mledon.png|800px|Figure-11: Led ON]]
+
[[File:Mledon.png|800px|Figure-4: Led ON]]
 
 
 
 
 
 
[[File:Mledoff.png|800px|Figure-12: Led OFF]]
 
 
 
 
 
=Windows Users=
 
 
 
This section is for those who are using a Windows machine to interact with the MinnowBoard.
 
 
 
==Serial Terminal==
 
 
 
We will be using Teraterm as our terminal application. Please follow the steps below to set up Teraterm:
 
 
 
'''Step-1:'''
 
 
 
Download the latest version of Teraterm using the link below:
 
 
 
[http://en.sourceforge.jp/projects/ttssh2/releases/ Teraterm]
 
 
 
At the time of writing this guide, the latest version was '4.78' .
 
 
 
 
 
'''Step-2:'''
 
 
 
Install the Teraterm software by double clicking on the exe file downloaded earlier. If it displays a security warning, accept it and click on 'Run' as shown in Figure - 13 below:
 
 
 
[[File:Mwindows1.png|500px|Figure-13: Teraterm installation]]
 
 
 
 
 
'''Step-3:'''
 
 
 
Now just follow the on-screen instructions to install the software. It is advised to do the 'full' installation instead of the 'standard' one as shown in Figure - 14 below:
 
 
 
[[File:Mwindows2.png|500px|Figure-14: Perform Teraterm full installation]]
 
 
 
 
 
'''Step-4:'''
 
 
 
Launch Teraterm. Then go to Setup>Serial port and change the settings as shown in Figure - 15 below:
 
 
 
[[File:Mwindows3.png|500px|Figure-15: Teraterm Serial Port setup]]
 
 
 
 
 
'''Step-5:'''
 
 
 
Then go to File>New connections and select the Serial option and chose the appropriate COM port as shown in Figure - 16 below
 
 
 
[[File:Mwindows4.png|500px|Figure-16: Setting up a new connection]]
 
 
 
 
 
'''Step-6:'''
 
 
 
Then connect the required accessories as described earlier in this guide and power up the MinnowBoard. If all went well, you should see a login screen in Teraterm as shown in Figure - 17 below:
 
 
 
[[File:Mwindows5.png|500px|Figure-17: Angstrom login]]
 
 
 
 
 
==Preparing the microSD card==
 
 
 
'''Step-1:'''
 
 
 
First, download the latest Angstrom Linux image from the link below:
 
 
 
[http://dominion.thruhere.net/koen/angstrom/minnow/production-Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img.xz Latest Angstrom Image]
 
 
 
 
 
'''Step-2:'''
 
 
 
Next, download the 7-zip utility from the link below and install it:
 
 
 
[http://www.7-zip.org/download.html 7zip]
 
 
 
 
 
'''Step-2:'''
 
 
 
Decompress the previously downloaded Angstrom image using 7-zip as shown in Figure - 18 below. The resulting file should have an extension '.img' .
 
 
 
[[File:Mwindows6.png|500px|Figure-18: Decompressing the image]]
 
 
 
 
 
'''Step-3:'''
 
 
 
Image Writer for Windows is needed to write the .img file to a microSD card. Download and install Image Writer using the link below: :
 
 
 
[http://sourceforge.net/projects/win32diskimager/files/latest/download Image Writer for Windows]
 
 
 
 
 
'''Step-4:'''
 
 
 
Insert the mircoSD card into the computer using an appropriate adapter. Next, launch the image writer software we just installed earlier. Select the Angstrom image and write it to the microSD card as shown in Figure - 19 below.
 
 
 
[[File:Mwindows7.png|500px|Figure-19: Writing the image to microSD card]]
 
 
 
 
 
=Mac Users=
 
 
 
This section is for those who are using OS X to interact with the MinnowBoard.
 
 
 
==Serial Terminal==
 
 
 
We will be using the 'screen' command which is by default a part of the bash shell on OS X. Now to use screen command, the FTDI driver(it is enables communication between the development board and computer over USB) has to be installed. Please follow the steps below to install it:
 
 
 
'''Step-1:'''
 
 
 
Download the latest ftdi driver for Mac OS X from the link below and make sure that you select the correct file corresponding to your computer architecture(32/64 bit):
 
 
 
[http://www.ftdichip.com/Drivers/VCP.htm FTDI Drivers]
 
 
 
 
 
'''Step-2:'''
 
 
 
Double click on the downloaded file to start the installation procedure.
 
 
 
 
 
'''Step-3:'''
 
 
 
You will have two files inside the downloaded driver package as shown below in Figure - 20. The first file, ending with 10_3 is specific for Mac OS X version 10.3 . The second file is for all other versions, newer than 10.3 .
 
 
 
[[File:Mmac4.png|600px|Figure-20: FTDI driver]]
 
 
 
 
 
'''Step-4:'''
 
 
 
Based on your Max OS X version, select the appropriate and double click it to proceed further.
 
 
 
 
 
'''Step-5:'''
 
 
 
You will now be greeted with an ftdi installer screen as shown in Figure - 21.
 
 
 
[[File:Mmac5.png|600px|Figure-21: FTDI installer screen]]
 
 
 
 
 
'''Step-6:'''
 
 
 
Proceed forward by pressing the 'continue' button till you reach the “installation type” screen as shown below in Figure -22.
 
 
 
[[File:Mmac6.png|600px|Figure-22: FTDI driver installation]]
 
 
 
 
 
'''Step-7:'''
 
 
 
Now press the 'install' button and wait for it to finish as shown in Figure - 23.
 
 
 
[[File:Mmac7.png|600px|Figure-23: FTDI driver installation in progress]]
 
 
 
 
 
'''Step-8:'''
 
 
 
If the installation was successful, you should be greeted by a screen similar to the one shown in Figure - 24
 
 
 
[[File:Mmac8.png|600px|Figure-24: FTDI driver installation successful]]
 
 
 
 
 
'''Step-9:'''
 
 
 
Then connect the required accessories as described earlier in this guide and power up the MinnowBoard.
 
 
 
If everything went well, you will see new entries in the /dev directory:
 
 
 
/dev/cu.usbserial-xxxxxxxx
 
/dev/tty.usbserial-xxxxxxxx
 
 
 
Here, xxxxxxxx is either the device's serial number or, for unserialized devices, a location string that depends on which USB port your device is connected to. /dev can be accessed through the Terminal application. The Terminal application can be launched by selecting Go > Applications > Utilities > Terminal. Now fire up the terminal in Mac OS X and type the following command in it:
 
 
 
$ cd /dev
 
 
 
 
 
'''Step-10:'''
 
 
 
Access the MinnowBoard's serial console via a terminal emulator and you should be greeted by the Angstrom screen as shown in Figure - 25:
 
 
 
$ sudo screen /dev/tty.usbserial-xxxxxxxx 115200
 
 
 
[[File:Mmac9.png|600px|Figure-25: Angstrom]]
 
 
 
==Preparing the microSD card==
 
 
 
'''Step-1:'''
 
 
 
First, download the latest Angstrom Linux image from the link below:
 
 
 
[http://dominion.thruhere.net/koen/angstrom/minnow/production-Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img.xz Latest Angstrom Image]
 
 
 
 
 
'''Step-2:'''
 
 
 
Next, install the “The Unarchiver” application(it is free) from the app store on Mac OS X as shown in Figure - 26
 
 
 
[[File:Mmac1.png|600px|Figure-26: The Unarchiver]]
 
 
 
 
 
'''Step-3:'''
 
 
 
Then unpack the downloaded angstrom image using the unarchiver application as shown below in Figure -27
 
 
 
[[File:Mmac2.png|600px|Figure-27: Unpacking the Angstrom image]]
 
 
 
 
 
'''Step-4:'''
 
 
 
Insert the microSD card into a microSD compatible writer in your computer. Now, identify the disk device filename for your microSD card. You can do this by typing the command below, before and after you insert the microSD card and comparing the outputs to see the newly added device:
 
 
 
$ df-h
 
 
 
''Note:- If you notice closely, the microSD card entry will be in the form of /dev/diskNsX where 'N' and 'X' are numbers. diskNsX is basically the device id of your microSD card. So, to obtain the raw device id from this, remove the 's' and 'X' from the device id. The raw device id should be in the form of diskN .''
 
 
 
 
 
'''Step-5:'''
 
 
 
Now, make sure all possible disk partitions from the microSD card are unmounted by typing the command below into your terminal: $ sudo umount /dev/diskN?* Here 'diskN' stands for the raw device id of the microSD card.
 
 
 
 
 
'''Step-6:'''
 
 
 
Now unpack the image to the microSD card by typing the command below in a terminal window:
 
 
 
$ sudo dd if=Angstrom-development-GNOME-image-eglibc-ipk-v2012.12-minnow-2013.07.10.img of=/dev/rdiskN
 
 
 
''Note:- In the above command we subtly replaced “diskN” with “rdiskN” because in the latter case, you are writing to a buffered device and hence the process becomes much faster!''
 
 
 
  
=Resources=
 
  
Please refer the websites below for more videos, tutorials, and projects you can do with your MinnowBoard:
 
  
#http://www.minnowboard.org/
+
[[File:Mledoff.png|800px|Figure-5: Led OFF]]
#http://www.elinux.org/Minnowboard
 
#http://www.angstrom-distribution.org/
 

Latest revision as of 19:29, 11 August 2013

Mlogo.png Back to the MinnowBoard home page


Minnow

Summary

In this guide, we will toggle a user LED on the MinnowBoard step-by-step. This guide is for beginners who are just getting started with the MinnowBoard.

Getting Started

For information on 'Setting up a microSD card', 'Booting Angstrom' etc, please refer here

User LED on the MinnowBoard

There are a total of five LED(s) on the MinnowBoard - D11, D12, D13, D14, D15 as shown in Figure -1. Their functions have been listed in the table below:


Figure-1: LED(s) on the MinnowBoard


Functions of the LED(s) on the MinnowBoard
Sr. No. LED Function
1 D11 Heartbeat/USER LED*
2 D12 microSD card activity/USER LED*
3 D13 PWR
4 D14 CPU HOT
5 D15 PWROK


Now, let us understand these functions in a bit more detail:

  1. Heartbeat: The Heartbeat LED blinks at a regular rate to indicate that the hardware is operating properly, and that the CPU hasn't locked up. This is useful in embedded systems where you may not always have a board connected to a display to confirm its operation.
  2. microSD Card Activity: This LED blinks when there is disk activity happening on the microSD card port.
  3. CPUHOT: When this LED is on, it indicates that the CPU temperature is abnormally high. This may suggest that the MinnowBoard is running in too hot of an environment, or that there is a problem with the CPU heatsink attachment. The MinnowBoard will shut off in the event that the CPU temperature reaches a level that could possibly damage itself, and CPUHOT represents a warning temperature before this state is reached.
  4. PWROK: This LED indicates that the power source is operating within required tolerances for the MinnowBoard.


So, there are two USER LED(s) on the MinnowBoard - D11 and D12 but by default they cannot be used as USER LED(s).


The user LED(s) are accessible via the user space in Linux at the location below on the filesystem:

/sys/class/leds

There is one directory per user LED, named as shown below:

/sys/class/leds/minnow_led0
/sys/class/leds/minnow_led1

Here, led0 is D11, while led1 is D12. Inside each one of those directories, there is a file named "brightness". If you write a "1" or a "0" to this file, then you can control the status of that led, i.e. , toggle it ON or OFF respectively.

Extra Credit

This is an optional section which you can read for further understanding. In a nutshell, we are trying to access the on board USER LED(s) via userspace in Linux. To be more precise we are using the sysfs interface. sysfs is a virtual filesystem which translates the hardware devices and busses attached to the system(board in our case) into a file system hierarchy that can be accessed from userspace. sysfs is generated by the kernel and always mounted at /sys. As discussed earlier, trigger for D11 and D12 LEDs has to be changed to make them function as USER LEDs. I would describe 'trigger' as the API used to link a LED to an 'event' in kernel space. Here, 'event' could be microSD card or Ethernet activity, heartbeat, power etc. To understand this better, take LED D11 for example. The trigger for D11 has been set by default to heartbeat. So, to use it as an USER LED, we have to change the trigger for it to 'none' as shown in Figure - 2 below:


Figure-2: Change LED Trigger


Steps

Now let us control that LED!

Step-1:

To use D11 as USER LED, we need to change its default trigger. Type the following command in your terminal to accomplish this:

echo none > /sys/class/leds/minnow_led0/trigger

Step-2:

Now we are ready to toggle the LED. Type the following commands in your terminal as shown in Figure - 3(First one is for turning ON and latter for OFF):

echo 1 > /sys/class/leds/minnow_led0/brightness
echo 0 > /sys/class/leds/minnow_led0/brightness


Figure-3: Toggle the LED


Output

You should see the LED change state as shown below:


Figure-4: Led ON


Figure-5: Led OFF