FreeRTOS
【中文】 全面的 FreeRTOS + STM32 学习资源,从入门到精通。 ✅ 详细移植教程与示例项目 ✅ 开发环境配置指南 ✅ 中英双语文档 适合初学者和专业开发者,加速您的嵌入式开发之旅! 【English】 Comprehensive FreeRTOS + STM32 learning resource from basics to advanced. ✅ Detailed tutorials with examples ✅ Development setup guides ✅ Bilingual documentation For beginners and pros - accelerate your embedded journey!
Install / Use
/learn @Despacito0o/FreeRTOSREADME
FreeRTOS Embedded Development Learning Library
<div align="center"> <p align="center"> <img src="https://www.freertos.org/fr-content-src/uploads/2018/07/logo-1.jpg" width="400"> </p> </div>📚 Project Overview
A comprehensive learning resource for FreeRTOS on STM32 microcontrollers. This repository provides step-by-step tutorials, fully functional example projects, and detailed guides to help you master embedded RTOS development.
Perfect for:
- 🎓 Beginners learning embedded systems
- 🔄 Developers transitioning to RTOS-based applications
- 🛠️ Engineers seeking practical STM32+FreeRTOS examples
- 📝 Students working on academic projects
🌟 Key Features
- 📖 Detailed FreeRTOS porting tutorials from basics to advanced topics
- 🔧 Complete STM32 development environment setup guide with troubleshooting tips
- 💡 Progressive learning path with practical example projects
- 🔄 Real-world demonstrations of RTOS concepts (tasks, queues, semaphores, etc.)
- 📝 Clear documentation in both English and Chinese
- 🔍 Common problem solutions and debugging techniques
🚀 Quick Start
1. Clone the repository
git clone https://github.com/Despacito0o/FreeRTOS.git
cd FreeRTOS
2. Follow the learning path
This repository is organized as a progressive learning journey, from basics to advanced:
| Level | Project Numbers | Focus | Skills Gained | |-------|----------|-------|--------------| | Beginner | 001-002 | Environment setup, FreeRTOS basics | Development setup, Basic concepts | | Intermediate | 003-006 | Task management, Memory models | Task creation/deletion, Memory optimization | | Advanced | 007-012 | Inter-task communication and synchronization | Parameters, Queues, Semaphores, Resource management |
3. Explore example projects
Each example builds on previous concepts, gradually increasing complexity and functionality:
| Number | Example Project | Description | Key Skills | |-------|----------|-------|--------------| | 001 | STM32 Project Template | Starting point for STM32 development | Standard peripheral library setup | | 002 | FreeRTOS Basic Example | First steps with FreeRTOS | Task creation and execution | | 003 | Dynamic Task Creation | Basics of multitasking | Dynamic memory allocation | | 004 | Static Task Creation | Memory-optimized task creation | Static memory allocation | | 005 | Project Enhancement | Adding UART, debugging capabilities | Peripheral integration & debugging | | 006 | Multi-Task Operations | Creating, deleting, and monitoring tasks | Task lifecycle management | | 007 | Task Parameters | Flexible task functions with parameters | Parameter passing techniques | | 008 | Queue Communication | Basic inter-task communication | Data sharing and transfer | | 009 | Advanced Queue Operations | Efficient data transfer techniques | Structured data transfer | | 010 | Binary Semaphores | Task synchronization and mutual exclusion | Resource protection & synchronization | | 011 | Counting Semaphores | Resource management and event counting | Resource pool management | | 012 | Priority Inversion | Understanding and solving priority inversion | System stability & real-time behavior |
📋 Project Structure
FreeRTOS/
├── docs/ # Documentation
│ ├── README.md # Documentation index
│ ├── en/ # English documentation
│ │ ├── 001-STM32-Development-Environment-Setup.md
│ │ ├── 002-FreeRTOS-Port-to-Keil6.md
│ │ ├── ...
│ │ └── 012-FreeRTOS-Priority-Inversion-Tutorial.md
│ └── zh/ # Chinese documentation
│ ├── 001-STM32标准库开发环境搭建教程.md
│ ├── 002-FreeRTOS移植到keil6.md
│ ├── ...
│ └── 012-FreeRTOS优先级翻转详解与实战教程.md
├── Despacito/ # STM32F103 example projects
│ ├── 001/ # STM32 project template
│ ├── 002/ # FreeRTOS basic example
│ ├── ...
│ └── 012/ # FreeRTOS priority inversion example
├── templates/ # Project templates
│ └── README_template.md # README template for examples
├── CONTRIBUTING.md # Contribution guidelines
├── CHANGELOG.md # Version history
├── LICENSE # MIT License
└── README.md/README_zh.md # Project documentation
📖 Documentation Navigation
📁 Core Documentation
Browse our comprehensive guides following the learning path:
- [001] STM32 Development Environment Setup
- [002] FreeRTOS Port to Keil6
- [003] FreeRTOS Dynamic Task Creation
- [004] FreeRTOS Static Task Creation
- [005] FreeRTOS Project Improvement Guide
- [010] FreeRTOS Binary Semaphore Tutorial (Chinese)
- [011] FreeRTOS Counting Semaphore Tutorial (Chinese)
- [012] FreeRTOS Priority Inversion Tutorial
📝 Project Resources
- Documentation Index - Navigate all available documentation
- Contribution Guidelines - How to contribute to this project
- Change Log - Version history and recent updates
🔍 Example Projects in Detail
🟢 Beginner Stage (Projects 001-002)
[001] STM32 Project Template
A clean, ready-to-use STM32F103 template with standard peripheral library, providing the foundation for all other examples.
[002] FreeRTOS Basic Example
Your first steps with FreeRTOS - demonstrates basic task creation and simple functionality with LED blinking.
🟠 Intermediate Stage (Projects 003-006)
[003] Dynamic Task Creation
Learn how tasks are dynamically created and scheduled in FreeRTOS, with practical examples of task priorities and scheduling.
[004] Static Task Creation
Explore static memory allocation for task creation - crucial for memory-constrained embedded systems.
[005] Project Enhancement
Take your project to the next level with UART communication, printf debugging, and optimized configurations - making development easier and more productive.
[006] Multi-Task Operations
Master task lifecycle management with dynamic creation and deletion, priority management, and state monitoring techniques.
🔴 Advanced Stage (Projects 007-012)
[007] Task Parameters
Make your tasks flexible and reusable by learning how to pass parameters using void pointers.
[008] Queue Communication
Implement reliable inter-task communication using queues, with examples of both simple message passing and structured data transmission.
[009] Advanced Queue Operations
Explore advanced techniques for efficient data transfer between tasks, including pointer-based methods and solutions for common pitfalls.
[010] Binary Semaphores
Master the use of binary semaphores for task synchronization and mutual exclusion.
[011] Counting Semaphores
Learn to use counting semaphores for resource pool management and event counting, with practical examples for advanced synchronization scenarios.
[012] Priority Inversion
Understand the priority inversion problem in real-time systems, its causes, and how to solve it using priority inheritance and mutexes.
🤝 Contributing
Your contributions make this resource better for everyone! Please read our Contribution Guidelines before submitting pull requests or issues.
Ways to contribute:
- 📝 Improve documentation and explanations
- 🐛 Fix bugs in example code
- ✨ Add new examples or tutorials
- 🌍 Help with translations
- 💡 Suggest improvements or enhancements
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👨💻 Author & Contact
- Despacito0o - FreeRTOS developer and tutorial creator
- Visit my CSDN Blog for more embedded development content
- Questions or suggestions? Open an issue or reach out directly!
🙏 Acknowledgments
- The FreeRTOS development team for their excellent documentation
- STMicroelectronics for their comprehensive peripheral libraries
- All contributors and community members who have improved this resource
<div align="center"> ⭐ If you found this helpful, please star the repository! ⭐ </div>
FreeRTOS优先级翻转实战教程:从代码到现象分析
前言
在实时操作系统中,优先级翻转是一个常见但又容易被忽视的问题。本文将通过实际代码演示优先级翻转现象,帮助大家深入理解这一概念。如果你对FreeRTOS有兴趣,可以访问我的完整学习资源:FreeRTOS学习库,从入门到精通的全面指南!
什么是优先级翻转?
优先级翻转是指高优先级任务被低优先级任务间接阻塞的现象。具体场景如下:
- 低优先级任务获取了某个共享资源
- 高优先级任务尝试获取同一资源,但因资源被占用而阻塞
- 中优先级任务此时可以抢占低优先级任务执行
- 结果:中优先级任务先于高优先级任务执行,违背了优先级调度原则
实战演示:创建优先级翻转场景
我们将创建三个任务,优先级依次为:
- Task1:低优先级(优先级2)
- Task2:中优先级(优先级3)
- Task3:高优先级(优先级4)
其中Task1和Task3需要共享同一个二值信号量,而Task2不使用该信号量。
1. 拷贝工程模板
首先,我们基于之前的二值信号量示例(010)创建新工程(012)。
.
commit-push-pr
84.1kCommit, push, and open a PR
