SAM7X Web Server & USB Mouse Demo
Using Eclipse, GCC and OpenOCD for a completely open
source development environment
[Embedded Ethernet Examples]
This demo uses FreeRTOS to create a simple web server and HID class mouse driver implementation on the AT91SAM7X-EK prototyping board
(instructions are provided should you wish to use an alternative development board).
The demo is configured to use Eclipse Europa,
the Yagarto GCC tools, OpenOCD
and the uIP mini TCP/IP stack. The small joystick built onto the AT91SAM7X-EK
is used to provide the mouse input.
FreeRTOS has made some modifications to the uIP stack since this demo was created. See the Embedded Ethernet Examples List page for more information.
The FreeRTOS zip file contains everything required other than the Eclipse and Yagarto tools.
Please follow these instructions carefully to install and configure Eclipse
correctly for use with this demo application.
The included OpenOCD executable and associated configuration files are set for use with
a Macraigor Wiggler compatible JTAG interface.
Note that uIP and OpenOCD are licensed separately from FreeRTOS.org. Users must familiarise themselves with the respective licenses.
Note to Linux users: Although all the tools used are cross platform - I have only tested the SAM7X/Eclipse build on a windows host.
IMPORTANT! Notes on using the Eclipse AT91SAM7X Web Server Demo
Please read all the following points before using this RTOS port.
See also the FAQ My application does not run, what could be wrong?
- Source Code Organisation
- The Demo Application
- RTOS Configuration and Usage Details
Source Code Organisation
The Eclipse workspace for the Eclipse SAM7X demo is located in the FreeRTOS/Demo/ARM7_AT91SAM7X256_Eclipse directory. This is the directory to
select when prompted for a workspace location during the Eclipse startup process. Be sure to read the
Eclipse installation and configuration instructions prior to building the project.
The FreeRTOS zip file download contains the files for all the ports and demo application projects. It therefore contains many more files
than used by this demo. See the Source Code Organization section for a description of the
downloaded files and information on creating a new project.
The Demo Application
Demo application setup
Connect the AT91SAM7X-EK prototyping board to a computer running a web browser either directly using a point to point (crossover) Ethernet
cable, or via a hub/router using a standard Ethernet cable. The prototyping board should also allow the use of a standard
Ethernet cable when connecting point to point, but I have not tested this configuration.
The IP address used by the demo is set by the constants UIP_IPADDR0 to
UIP_IPADDR3 within the file Demo/ARM7_AT91SAM7X256_Eclipse/RTOSDemo/FreeRTOSConfig.h.
The IP addresses used by the web browser computer and the prototyping board must be compatible.
This can be ensured by making the first three octets of both IP addresses identical.
For example, if the web browser computer uses IP address
192.168.100.1, then the prototyping board can be given any address in the range 192.168.100.2 to 192.168.100.254 (barring
any addresses already present on the network).
The MAC address used by the demo is set by the constants UIP_ETHADDR0 to UIP_ETHADDR5, also within FreeRTOSConfig.h.
You must ensure that the configured MAC address is unique on the network to which the prototyping board is being connected.
The demo application uses the LEDs built into the prototyping board so no other hardware setup is required.
Building the demo application
Again - please refer to the Eclipse installation and configuration instructions
for more detailed information.
- Ensure the Yagarto (or equivalent) GCC tools are installed, and that the Yagarto/bin directory is
included within your PATH environment variable.
- Open the FreeRTOS/Demo/ARM7_AT91SAM7X256_Eclipse Eclipse workspace.
- Ensure the FreeRTOS_ROOT variable has been configured.
- Press F7 (or select "Build All" from the "Project" menu) to build the demo application.
Running the demo application
Once again - please refer to the Eclipse installation and configuration instructions
for more detailed information.
If you then wish to commence a debugging session:
Ensure the Wiggler JTAG debug interface is connected and that the AT91SAM7X-EK development board is powered up.
Ensure an Ethernet cable is connected as described above.
Select "OpenOCD Programmer" from the "Run | External Tools" menu - then wait for the programming to complete. This will take approximately 20 seconds on
a relatively fast PC.
- Select "OpenOCD Server" from the "Run | External Tools" menu.
- Note:You may then receive an error message "DBGACK set while target was in unknown state. Reset or initialize target before resuming".
If this is the case, simple stop the server (click the red square above the error output on the console), then start it again using the "Run | External Tools" menu
item again. The error message should only appear on the first attempt.
- Switch to the debugging perspective.
- Select the OpenOCD server executable within the Debug pane.
- Click the "Debug RTOSDemo" speed button (the one with the little green bug icon).
The demo application creates 27 tasks. These tasks consist predominantly of the standard
demo application tasks (see the demo application section for details of the individual tasks).
The following tasks/functions are created in addition to the standard demo tasks:
- The uIP task
This task handles all the network processing. It will spend most of its time blocked on a semaphore - waiting to be woken by interrupts generated
by incoming network packets.
- A USB task
This handles the USB enumeration. Once enumerated, the USB task periodically reads the joystick built onto the SAM7X EK. Any joystick inputs are provided
to the host computer as mouse inputs. Note that this functionality will only work when running the demo 'stand alone', without the debugger.
- The 'check' tick hook
A tick hook function is used to monitor the standard demo tasks - with LED
DS4 being used to indicate the system status. DS4 toggling every 5 seconds
indicates that all the standard demo tasks are executing without error. The
toggle rate increasing to 500ms is indicative of an error having been found
in at least one demo task.
When executing correctly the demo application will behave as follows:
- LEDs DS1, DS2 and DS3 are under control of the 'flash' tasks. Each will flash at a constant frequency, with DS1 being
the fastest and LED DS3 being the slowest.
- The 'check' function will toggle LED DS4 every 5 seconds.
- The target hardware will serve the web pages described below to a standard web browser. To connect to the target:
- Open a web browser on the connected computer.
- Type "HTTP://" followed by the target IP address into the browsers address bar.
Entering the IP address into the web browser
(obviously use the correct IP address for your system)
- The joystick on the SAM7X EK will provide mouse inputs to the host computer. The mouse will only function when not using the debugger.
Served Web Pages
The top of each served page includes a menu containing a link to every other page.
The served RTOS stats page
The RTOS stats page provides run time information on the state of each task within the system - including the stack high water mark (the minimum amount of stack
there has been available at any time since the task started executing). The page will reload approximately every two seconds - depending on network load.
This page is transmitted in three sections - the HTML header and menu, the dynamically generated content, then finally the HTML footer. This makes the page relatively
fast to load. It could be optimised further by transmitting the entire page in one go.
The continuous reloading can sometimes make navigating away from the RTOS stats page a little tricky.
The served IO page
The IO page provides a simple interface that demonstrates data being sent to the SAM7 microcontroller.
The check box permits the state of the LED DS4 to be set and queried. Changes are sent to the target hardware by clicking the "Update IO" button. Note that the LED
DS4 is also under control of the 'check' tick hook so will toggle every 5 seconds - overwriting any commands sent from the web server.
The TCP Stats and Connections pages display run time networking information. Note that these pages transmit each line individually so will not load quickly.
This demonstrates how memory usage can be optimised through the use of a small transmit buffer by sacrificing the achieved data throughput.
This demo uses the FreeRTOS SAM7S GCC port - important usage information can be found on the SAM7X/Rowley CrossWorks demo documentation page.
Please read the usage information provided on the linked page!
Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2013 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.