Building a web-enabled application
Web serving embedded applications become a lot more useful when the web interface can be used to control the device, or monitor sensor inputs. In this step, we will build and experiment with a simple web-enabled application controlling the LEDs on the LX9 MicroBoard.
Create a new application
--> cd $PETALINUX
--> petalinux-new-app ControlLEDs
Using a CGI script
The Common Gateway Interface (CGI) is a standard method for web servers software to delegate the generation of web pages to executable files. Such files are known as CGI scripts; they are programs, often stand-alone applications, usually written in a scripting language. Our cgi-script is written in c and consists of a number of c program files. The package can be download from here. After unzipping, unpacking and copying the files to the apps directory it looks like this:
Enable the new application
We will enable the ControlLEDs application and disable the TourSkating application.
--> cd $PETALINUX
Build a new image
Compile the application and update the PetaLinux image by running:
--> make all romfs image
Booting the new image
This time we will boot the hardware board. For more information see part 76.
1. First bootstrap the system by downloading u-boot via JTAG.
--> cd $PETALINUX/software/petalinux-dist
--> petalinux-jtag-boot -i images/u-boot.elf
2. After u-boot boots, in the console check whether the TFTP server IP address is set to the IP Address of the host where the image resides.
3. Use the command /sbin/ifconfig to find the IP address.
4. In the PetaLinux console type
--> u-boot> print serverip
5. If not set, set the server IP addreess to the host IP address.
--> u-boot> set serverip <HOST IP ADDRESS>
6. Run netboot to download the PetaLinux image with the TFTP and boot it.
--> u-boot> run netboot
Start the httpd service
Login to the board and start httpd:
# httpd -p 8080 -h /home/httpd
Files in httpd directory
The led.cgi script can be found in the cgi-bin directory.
Controlling hardware from the web browser
We can now control the LEDs on the LX9 MicroBoard from our webbrowser.
- Open the web browser
- Enter the webaddress: <IP address of the board>:8080/cgi-bin/led.cgi
- CGI Blinkenlight will open
- Enter the LED GPIO ID. In our case it is 252
- Click the ON/OFF links to turn on/off the LEDs on the board
Top Previous Next