Systems and Network Programming for Embedded Linux
Duration: 5 Days
Course Background
Complex Linux projects typically involve a detailed knowledge not only of C programming, data structures and algorithms and of the Posix API but, also the ability to construct complex frameworks and make them accessible through intuitive and well thought out APIs. Complex embedded Linux systems quite commonly provide services for a networked collection of client devices. This is a common pattern used in the development of industrial controls systems for example, and also an increasingly important pattern in the development of Internet of Things (IoT) systems. It is also becoming more common, e.g. in complex robotics systems to have smaller embedded systems e.g. PIC or AVR or ARm Cortex-M based serving as intelligent controllers and sensors and communicating with a more powerful embedded Linux node running a powerful ARM, Intel or PowerPC processor based platform, for example. This course is concerned with ARM platforms, though it can be tailored to other platforms if so required.
Course Prerequisites and Target Audience
A sound basic knowledge of C, preferably in the context of embedded systems application development is assumed, to the level covered e.g. in the Introduction to Embedded Linux C programming and a knowledge of Linux/Unix shell programming, tools and utilities. course.
Course Overview
The course focuses on extending the basics of Posix API programming to cover the design and implementation of more complex frameworks and services. As opposed to implementing complex high performance IT server applications the emphasis here is on embedded systems applications. These applications can range from building and office acess control and HVAC applications through to manufacturing process control applications and advanced robotics applications. The standard version of this course will use C only as the high level programming language. The course can be adapted and tailored to include C++ and to cover topics such as CORBA, ACE + TAO and C++11 multithreading. The course modules include coverage/overviews of
- Advanced data structures and algorithms - e.g heaps, data compression, memory management
- Intensive overview of the Posix API standards as used in Linux
- Synchronous and asynchronous programming using the Sockets API
- Memory mapping for efficient resource sharing between tasks
- The strengths and weaknesses of multi-threading
- Taking advantage of multi-core processor architectures
- Basic and advanced multi-tasking and inter-process communitation patterns
- Logging and loggers
Lab exercises are used to consolidate key concepts.
The course uses PC workstation and Embedded Linux systems (e.g. BeagleBone Black and RaspberryPi) as the platforms for hands-on work and Arduino boards for exploring smart sensor and control applications. [Note: Although the use of Arduino sketches can be included in the course if required, the approach taken here is a "bare bones" programming approach using C code. ]
Course Benefits
Students successfully completing this course will have a deeper understanding of C and Posix API programming that goes beyond the simple examples covered in many basic courses and books. Students will also be exposed to various advanced data structures and algorithms that they may have forgotten or that were not covered thoroughly on various undergraduate and postgraduate courses they may have attended.
Course Outline
- Intensive overview of essential C concepts and idioms
- Data types, data structures, pointers and arrays
- Using pointers to search collections of data
- Arrays and buffers
- Circular buffers
- Polygonal buffers
- I/O vectors
- Understanding GCC Extensions to the C Language
- Make - beyond the basics
- Linked Lists in depth
- Singly linked and doubly linked lists
- Using lists to implements FIFO queues and LIFO queues (stacks)
- Using lists of linked lists
- Using linked list nodes containing void * pointers to implement heterogeneous collections of data
- Using linked lists to implement resizeable arrays
- Binary trees, their uses and their relations
- Basic binary trees
- Self-balancing binary trees (AVL, Red-Black, Splay)
- Heaps and their uses
- Huffman encoding
- Priority queues
- Error detection
- CRC checksums (16 bit and 32 bit)
- Implementing simple memory management schemes
- State Machines and Statecharts
- Event driven programming
- Basic FSMs
- State driven hardware and communication protocols
- Techniques for Implementing FSMs
- Extended FSMs and hierarchical FSMs
- Statecharts
- Hierachical FSMs and extended FSMs (simple statecharts)
- Orthogonal statecharts and concurrency
- Active objects - linking multi-tasking, message passing and event driven programming
- The Posix API - an Intensive Overview
- An overview of the Posix Standards
- Posix Standards used in Linux
- Kernel space vs. User space
- System calls for switching between kernel space and user space
- Manipulating file systems, files and directories in Posix
- Using fork and exec to spawn new tasks
- Inter process communication using pipes and named pipes
- Threads under Linux and the PThreads API
- The Sockets API and network programming
- Virtual memory and memory mapping
- Mutexes, Semaphores and Condition Variables
- Important Inter-Process Communication Idioms
- Producer - Consumer
- Monitors
- Readers and Writers
- Workcrew
- Synchronous vs. asynchronous programming idioms
- Blocking vs. non-blocking system calls
- Overview of synchronous vs. asynchronous socket programming
- Remote Procedure Call (RPC) Programming
- Introduction to load balancing and proxy servers
- Introduction to Libevent and Libevent programming
- Daemons and Servers
- Intensive overview of IPv4, IPv6, TCP, UDP , ICMP and DNS
- Basic Template for Implementing a Server Daemon
- Programming Unix Domain Sockets , TCP Sockets and UDP Sockets in Depth
- Remote Procedure Call (RPC) Programming
- Introduction to load balancing and proxy servers
- Posix Clocks and Timers
- Posix clocks
- Sleeping, waiting and timing out
- Remote Procedure Call (RPC) Programming
- Introduction to load balancing and proxy servers
- Protocol tracing, sniffing and analysis
- libpcap - an overview
- Filters and filtering - essential concepts
- Practical programming with pcap
- Logging and Loggers
- Overview of Syslog
- Introduction to log4C
- Thread safety and log4C programming
- Implementing Services for Smart Sensors and Controllers
- Overview of small embedded system devices
- Communicating with small embedded devices over USB, Ethernet, I2C and SPI, RS232 and RS485
- Overview of BACNet and KNX
- Examples and Case Studies