logo资料库

Real-time Operating Systems Book 2 – The Practice.pdf

第1页 / 共348页
第2页 / 共348页
第3页 / 共348页
第4页 / 共348页
第5页 / 共348页
第6页 / 共348页
第7页 / 共348页
第8页 / 共348页
资料共348页,剩余部分请下载后查看
Book outline
Preface
Table of Contents
==================== Part 1 ====================
Developing the practical code - Processes, tools, toolchains and hardware
1.1 Design to code - a practical approach
1.1.1 Overview.
1.1.2. Source code production.
1.1.3. Target code production.
1.2. The STM32Cube software tool - an introduction.
1.2.1. Tool overview.
1.2.2. STM32CubeMX features.
1.2.3. STM32Cube embedded software libraries and documentation.
1.3. The practical toolset.
1.3.1 Hosting the software tools - Integrated Development Environments.
1.3.2 The hardware - STM32F4 Discovery kit.
1.4. The STM32Cube graphical tool - STM32CubeMX details.
1.4.1. Overview
1.4.2. Selecting the microcontroller.
1.4.3. Using the pinout wizard to set pin functions.
1.4.4. Generating the code.
1.4.5. Automatically-generated code: the really important points.
1.4.6 The next step.
1.5. The STM32Cube HAL.
1.6. Incorporating FreeRTOS in your project - a brief introduction.
Appendix A - Example using FreeRTOS in a Cube project
=================== Part 2 =====================
The practical exercises - introduction
Overview of the exercises
Preliminary exercise – Learn how to drive the LEDs and handle the pushbutton signal of the STM32F407G-DISC board.
P.1 Introduction.
P.2 The problem.
P.3 Implementing the design.
Review.
Preliminary exercise addendum - APIs
(i) Set/reset a pin output signal.
(ii)Toggle a pin output signal.
(iii) Get the status of the User pushbutton signal.
Exercise 1 – Create and run a single task that executes repeatedly.
1.1 Introduction.
1.2 The problem.
1.3 Implementing the design - exercise 1(a).
1.4 Modifying the code - using the osDelay function (exercise 1b).
1.5 Modifying the code - using native FreeRTOS constructs.
1.6 A further design exercise.- exercise 1c.
Review.
Exercise 1 addendum
Exercise 2 – Create and run a single periodic task having an accurate periodic time.
2.1 Introduction to the problem.
2.2 The problem.
2.3 Evaluation of the exercises.
2.4 Additional exercise.
Review.
Exercise 2 addendum - Description of the DelayUntil function.
Exercise 3 – Create and run multiple independent periodic tasks.
3.1. Introduction to the problem.
3.2 The problem.
3.3 Implementing the design.
Review.
Exercise 4 - Gain a good understanding of task behaviour where a priority preemptive scheduling policy is used.
4.1 Introduction to the problem.
4.2 Problem overview.
4.3 The problem details.
4.4 Exercise details.
Review.
Exercise 5 – Demonstrate access contention problems when using shared resources in a multitasking system.
5.1 Introduction to the problem.
5.2 The problem - overview.
5.3 The problem - exercise details.
5.3.1 General aspects.
5.3.2 Specific aspects.
5.3.3 Additional check (optional).
Review.
Exercise 6 – Demonstrate a simple way to eliminate resource contention - suspending the scheduler.
6.1 Introduction.
6.2 Exercise details
Review.
Exercise 7 – Demonstrate that the sharing of resources in a multitasking design can lead to a deterioration in system performance.
7.1 Introduction.
7.2 Exercise details
7.2.1 Problem overview and key code aspects.
7.2.2 Exercises - specific aspects.
Review.
Exercise 8 – Demonstrate how to eliminate resource contention in a selective manner - using a semaphore to protect the critical code section
8.1 Introduction
8.2 Exercise details.
8.2.1 Introduction and semaphore creation.
8.2.2 Using the semaphore.
8.2.3 Exercise content.
Review.
Exercise 9 – demonstrate how to eliminate resource contention in a selective manner - using a mutex to protect the critical code section.
9.1 Introduction and exercise details.
Review.
Exercise 10 – Demonstrate that encapsulating an item with its protecting semaphore improves the safety and security of software.
10.1 Introduction to the problem.
10.2 Problem overview.
10.3 The problem details.
Review.
Exercise 11 – Demonstrate the effects of priority inversion in a multitasking design.
11.1 Introduction.
11.2 Problem overview and key code aspects.
11.3 Exercise details.
11.3.1 Overall aspects.
11.3.2 Exercise 11.1.
11.3.3 Exercise 11.2.
11.3.4 Exercise 11.3.
11.3.5 Exercise 11.4.
Comment and review.
Exercise 12 – Demonstrate that priority inversion of tasks can be eliminated by using priority inheritance techniques.
12.1 Introduction.
12.2 Problem overview.
Comment and review.
Exercise 13 – Show how flags can be used to coordinate activities.
13.1 Introduction.
13.2 Problem overview.
13.3 Problem detailed points.
Comment and review.
Exercise 14 – Show how event flags can be used to provide unilateral synchronization of tasks.
14.1 Introduction.
14.2 Event flags, signals and FreeRTOS/CMSIS.
14.3 Exercise details.
Comment and review.
Exercise 15 – Show how semaphores can be used as event flags for unilateral synchronization purposes.
15.1 Introduction and problem outline.
15.2 Exercise details.
Comment and review.
Exercise 16 – Show how semaphores can be used to provide bilateral synchronization of tasks.
16.1 Problem overview.
16.2 The problem in detail.
Comment and review.
Exercise 17 – Show how semaphores can be used to provide synchronization of multiple tasks - the 'Rendezvous Barrier'.
17.1 Problem overview.
17.2 The problem in detail.
17.3 One-semaphore implementation of the Rendezvous Barrier.
17.4 N-semaphore implementation of the Rendezvous Barrier.
Comment and review.
Exercise 18 – Show how the pool is used to support data transfer between tasks without any synchronizing actions.
18.1 Introduction to the problem.
18.1.1 The pool.
18.1.2 Constructing the Pool.
18.1.3 Important implementation factors - using native FreeRTOS code.
18.2 The problem details.
18.2.1 Overall aspects.
18.2.12 Exercise timing details.
18.2.13 Exercise - detailed points.
Review.
Exercise 19 – Show how the queue is used to support data transfer between tasks without any synchronizing actions.
19.1 Introduction to the queue.
19.2 Exercise details - overall.
19.3 Exercise details - specific aspects.
19.3.1 The queue - detailed features and handling operations.
19.3.2 Important implementation factors
Review.
Exercise 20 – Show how the mailbox is used to support data transfer between tasks at designated synchronization points.
20.1 Introduction to the mailbox.
20.2 Building the mailbox.
20.3 Exercise details.
Review.
Appendix - using FreeRTOS APIs to construct the mailbox.
Exercise 21 – Learn how to implement a push-button generated interrupt service routine (ISR).
21.1 Introduction to the problem.
21.2 Using CubeMX to generate the ISR skeleton code.
21.3 Exercise details.
Review.
Exercise 22 – Show that using lengthy interrupt-driven aperiodic tasks in multitasking designs can seriously affect system temporal behaviour.
22.1 Exercise overview and timing details.
22.2 Some CubeMX issues.
Review.
Exercise 23 – Show how to minimize the effects of interrupt-driven aperiodic tasks by using the deferred server technique.
23.1 Deferring responses to interrupt signals.
23.2 Exercise overview and timing details.
23.3 Code generation and run-time aspects.
Review.
===================== Part 3 =====================
Useful, helpful and informative online material
3.1 STM32Cube embedded software.
3.2 STM32CubeMX features.
3.3 STM32Cube embedded software libraries and documentation.
3.4 The hardware - STM32F4 Discovery kit.
3.5 Useful and informative videos.
3.5.1 Tutorial CubeMX - 1 - GPIO Out STM32F4Discovery STM32CubeMX.
3.5.2 Tutorial CubeMX - 2 - Write HAL Port functions
3.5.3 Tutorial STMCubeMX - 3 - GPIO In Out on STM32F4 Discovery
3.5.4 Tutorial CubeMX - 4 - External Interrupts EXTI.
3.5.5 Tutorial Cube MX -5- USART polling STM32F4 Discovery.
3.5.6 Tutorial CubeMX - 6 - Tx polling Rx interrupts STM32F4 Discovery.
3.5.7 Tutorial CubeMX - 7- USART RxTx Interrupts STM32F4 Discovery.
3.5.8 Tutorial CubeMX - 8 - ADC_DMA+USART_DMA STM32F4 Discovery.
3.5.9 Tutorial Cube MX - 9 - DAC ADC USART on STM32F4Discovery.
3.5.10 Tutorial Cube MX - 5 - FreeRTOS STM32F4 CubeMX.
3.5.11 #1 STM32CubeMX Tutorial.
3.5.12 #2 How the cube generates the code.
3.5.13 #3 STM32CubeExamples.
3.5.14 #5 STM32CubeMX Power Consumption Calculator.
3.6 FreeRTOS documentation.
3.7 Percepio Tracealyzer RTOS trace analysis tool.
==================== Part 4 ====================
Visualization of software behaviour using Tracealyzer - introduction
Tracealyzer exercise listing
Tracealyzer exercise 1
Tracealyzer integration and setup guide.
Tracealyzer exercise 2
Tracealyzer basics
Tracealyzer exercise 3
Evaluating trace recordings
Tracealyzer exercise 4
Run-time analysis of a two-task design
Tracealyzer exercise 5
Investigating priority preemptive scheduling
Tracealyzer exercise 6
Evaluating the FreeRTOS delay functions
Tracealyzer exercise 7
Introduction to Tracealyzer’s streaming mode of operation
Tracealyzer exercise 8
Mutual exclusion - using protected shared resources
Tracealyzer exercise 9
Evaluating queue operations
Tracealyzer exercise 10
Evaluating task synchronization with data transfer
Tracealyzer exercise 11
Interrupt-driven deferred server operations
===================== Part 5 =====================
Epilogue - looking to the future
5.1 The influence of work practices.
5.2 OS and related issues.
5.3 Portability of application code.
5.4 Code structuring at the application level.
A closing comment.
The engineering of real-time embedded systems
Real-time Operating Systems
Book 2 - The practice Using STM Cube, FreeRTOS and the STM32F4 Discovery boards Jim Cooling Published by Lindentree Associates © 2017 The rights of James E Cooling to be identified as author of this work has been asserted by him in accordance with the Copyright, Design and Patents Act 1988. Dedication: For my granddaughter Eilish Siobhan Cooling Labhraíonn na páistí spás i do chroí nach raibh a fhios agat riamh ann (Grandchildren fill a space in your heart that you never knew was there) Overall contents listing Preface. Part 1: Developing the practical code - Processes, tools, toolchains and hardware. Part 2: The practical exercises. Part 3: Useful, helpful and informative online material Part 4: Visualization of software behaviour using Tracealyzer Part 5: Epilogue - looking to the future
Preface Why this book? When you want to become expert in any technical subject you need to understand its theoretical aspects (hardly a ground-breaking piece of advice but true all the same). I call that the 'head's' appreciation. But if you want to become truly proficient this isn't enough - you need to have the 'heart's' understanding as well. By that I mean getting a real feel for the subject. And, in my opinion, the best way to do this is to put your theory into practice: learn-by-doing. If you look around you'll find many people fall into one or other of the two categories. Leading the field of 'head' experts are University-based computer science theoreticians and the like. In complete contrast the classical 'heart' experts are self-taught programmers with little or no understanding of the subject basics. Rather a large gap here, methinks; and these books set out to help close that gap. Volume 1 of this book deals with the 'head' aspects; volume 2 leads into the 'heart' of the matter. Use this material to help you become expert by turning theory into practice. Now, while that seems to be a good idea in theory, the practice is a bit more challenging. First, you need a sensible, practical toolset on which to carry out the work. Second, for many self-learners, cost is an issue; the tools mustn't be expensive. Third, they mustn't be difficult to get, use and maintain. So what we have here is our approach to providing you with a low cost toolset for RTOS experimentation. The practical tools. The toolset used for this work consists of: A graphical tool for configuring microcontrollers (specifically STM32F variants) - STM32CubeMX software application. An Integrated Development Environment for the production of machine code.
A very low cost single board computer with inbuilt programmer and debugger All software, which is free, can be run on Windows, OSX or Linux platforms. The Discovery kit is readily available from many electronic suppliers. The RTOS used for this work is FreeRTOS, which is integrated with the CubeMX tool. All the exercises given here are designed to execute on the the STM32F4 Discovery kit, http://www.st.com/en/evaluation-tools/stm32f4discovery.html. (confusingly this is also called the STM32F407G-DISC1 board). You can, if you wish, use the cheaper STM32L100C Discovery kit, http://www.st.com/en/evaluation-tools/32l100cdiscovery.html. The philosophy of this book.
The fundamental philosophy of this book is that 'theory is best understood by putting it into practice'. Great: I think that we can all sign up to that. But then a really important question arises; exactly how should we do it? And underlying that question is an even more basic one; what precisely do we want to achieve? Suppose, for example, you're filled with a burning desire to make your own wooden chair based on the one shown below in figure 1: Figure 1 The intended product Unfortunately you don't have any carpentry knowledge or experience. So you set about learning the theory of carpentry and, armed with this, launch into your project. Well, you may not end up with something as disastrous as that shown in figure 2 but it's pretty unlikely to be a professional job.
Figure 2 The actual product What should you have done instead of just jumping into the project, expecting (hoping?) that all will turn out well? It's blindingly clear that before starting any real project you first need to learn what the tools of the trade are and how to use them. Thus, as a novice carpenter, we'll start with the traditional woodworking toolset shown in figure 3.
分享到:
收藏