Phase 3: Building a FreeRTOS application on STM32L475 (B-L475E-IOT01A) from Scratch
No IDE | GCC | Make | OpenOCD
đź§ The Mission
Escaping the abstraction of proprietary IDEs to build a production-grade FreeRTOS environment from raw source code. This phase focuses on the “plumbing” of embedded systems—mastering the build process, dependency management, and hardware bring-up without the “magic” of code generators.
đź› Core Objectives
1. Toolchain Independence
- GCC & Make: Replacing “Click-to-Build” buttons with manual compilation rules,
vpathsource discovery, andwildcardfile handling. - Linker Mechanics: Understanding memory layout (
.text,.data,.bss) and manually configuring the STM32L475 Flash/RAM partitioning via.ldscripts. - Garbage Collection: Utilizing
-ffunction-sectionsand--gc-sectionsto strip unused HAL drivers from the final binary.
2. Manual BSP Integration (The “Hunt”)
- Driver Extraction: Manually gathering CMSIS core headers, STM32L4 HAL drivers, and Startup Assembly code from vendor SDKs.
- Dependency Resolution: Solving complex include chains (Legacy headers, Extended
_exdrivers) and eliminating conflicting template files. - Interrupt Mapping: Manually mapping FreeRTOS kernel handlers (
SVC,PendSV,SysTick) to the STM32 vector table.
3. OS Configuration
- Minimal Config: Crafting a
FreeRTOSConfig.hfrom scratch, tailored specifically for the Cortex-M4F. - Hook Management: configuring the OS to run without standard hooks (Idle, Tick, Stack Overflow) for initial bring-up simplicity.
🚀 Key Milestones
- The Clean Architecture: A modular project structure separating
Drivers,Middlewares, andApplicationcode. - The Bulletproof Makefile: A robust build script capable of compiling the entire HAL + OS stack.
- Alive on Hardware: A validated Green LED blink (PB14) driven by the FreeRTOS scheduler, flashed and verified using OpenOCD.
Table of contents
- Setting up environment for Building a FreeRTOS application on STM32L475 from Scratch
- 01. FreeRTOS Migration, Hybrid Memory and using Queue for IPC
- 02. Building a Robust FreeRTOS Application
- 03. Data Persistence & Command Line Telemetry
- 04. System Reliability & Hardware Offloading
- 05. USB Classes - CDC, HID and MSC
- Strategic Roadmap: Phase 3 & Production-Grade Future Scope
- Establishing MISRA C & Complexity Quality Gates
- Lesson learned