Menu

QP integrated with lwIP TCP/IP stack

The open source lwIP TCP/IP stack has been natively integrated with the QP state-machine frameworks. The newly released QP-lwIP integration example code available for download from www.state-machine.com/lwip provides all you need to develop professional TCP/IP applications with lwIP, including embedded code and host-based utilities.

The example code accompanying the extensive Application Note (see http://www.state-machine.com/lwip/AN_QP_and_lwIP.pdf) runs on the LM3S6965 Cortex-M3 MCU with integrated Ethernet MAC and PHY. But the QP-lwIP integration has been carefully designed for portability. All hardware-specific code is clearly separated in the Ethernet/lwIP device driver with the clean interface to the lwIP stack and the QP application.

The example code is based on the Dining Philosopher Problem (DPP) sample application described in Chapter 7 of PSiCC2. The goal is to demonstrate lwIP running alongside an existing real-time application, as opposed to lwIP running all by itself that fails to show how lwIP can share the CPU and cooperate with other software components. The QP-lwIP example code includes the following components:

  • The DPP example with lwIP for the cooperative “vanilla” kernel described in Chapter 7 of PSiCC2
  • The DPP example with lwIP for the preemptive QK kernel described in Chapter 10 of PSiCC2
  • lwIP source code version 1.3.0 (available also from http://savannah.nongnu.org/projects/lwIP)
  • lwIP Ethernet device driver for the Luminary Micro Stellaris MCUs
  • The web server (HTTP-Daemon) with Server-Side Includes (SSI) and rudimentary Common Gateway Interface (CGI) capabilities
  • The makefsdata.pl Perl script for generating ROM-based file system data for the web pages
  • Example website consisting of multiple HTTP pages, graphics, and examples of SSI and CGI
    *lwIP Example of using UDP communication to and from the embedded target
  • The qudp.exe host utility for generating and receiving UDP packets to and from the target

QP-lwIP integration has been carefully designed for hard real-time control-type applications, in which the TCP/IP stack is used to monitor and configure the embedded device as well as to provide remote user interface (e.g., by means of a web browser). In particular, The lwIP stack, which is not reentrant, is strictly encapsulated inside a dedicated active object (lwIP-Manager), so interrupt locking is unnecessary, which is critical for low interrupt latency. Also, the Ethernet interrupt service routine (ISR) runs very fast without performing any lengthy copy operations. This means that hard-real-time processing can be done at the task level, especially when you use the preemptive QK kernel built into QP for executing your application. No external RTOS component is needed to achieve fully deterministic real-time response of active object tasks prioritized above the lwIP task.

The QP-lwIP integration uses exclusively the event-driven lwIP API. The heavyweight Berkeley-like socket API requiring a blocking RTOS and is not used, which results in much better performance of the lwIP stack and less memory consumption.

The lwIP source code has not been modified in any way to match the event-driven, run-to-completion execution model underlying QP. In other words, QP works with the standard lwIP code, as distributed from the lwIP homepage at http://savannah.nongnu.org/projects/lwip.

Posted by Quantum Leaps 2009-03-24

Log in to post a comment.