Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

移植FreeRTOS 之嵌入式軟體研究與開發

6,397 views

Published on

21天移植FreeRTOS 到Raspberry Pi 2

Published in: Engineering
  • Be the first to comment

移植FreeRTOS 之嵌入式軟體研究與開發

  1. 1. FreeRTOS嵌入式系統移植研究 21天移植FreeRTOS 組長 :黃0閔 組員 :陳0丞、郭0澤、高0穎 專題指導老師 : Joseph 105 艾鍗科技嵌入式Linux系統工程師人才養成班 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  2. 2. 21DAYS FREERTOS PORTING ON RASPBERRY PI2 •Raspberry Pi2: 900 MHz quad core ARM Cortex-A7 CPU 1GB RAM 4 USB ports 40 GPIO pins 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  3. 3. WHAT IS RTOS •General purpose OS: • Linux • Windows •Real-Time OS (RTOS): • Without buffering delays • Hard real-time • Soft real-time Hard real-time Soft real-time Program no response while landing 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  4. 4. TODAY RTOS ON MCU • MCU: • Data bus From 8bit to 32bit • CPU clock ARM Cortex-M (60MHz ↑) • RTOS: Multi-task Small code size RTOS TasksTasks TasksTask MCU & Peripheral Peripheral Drivers MCU & Peripheral Peripheral Drivers 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  5. 5. RTOS FEATURE •Task scheduler: Task create Task save Task restore Invoke task switch (timer interrupt) Task communication: Queue, semaphore,…etc • Memory Management 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  6. 6. RTOS • RTOS: • FreeRTOS, QNX, uC/OS, RTEMS • FreeRTOS: Free open source Small: 9000 lines code Simple : Only 3 ~ 4 files for porting Multi-platforms:ARM-M series, ARM7, Cortex-A(A8, A9) 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  7. 7. DEVELOPMENT TOOL • IDE: Eclipse-cdt 4.4.2 • Toolchain: gcc (arm-none-eabi-4.9) • Debug Tool: ICE, J-link, nu-link, st-link LED, UART 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  8. 8. ARM BOOT AND INTERRUPT _start: Usually start from 0x0000 Interrupt table 0x0000~0x001C (7 mode) rest: Basic hardware, memory initialize and jump into OS main function 0x00 … … 0x1C Interrupt Table RAM 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  9. 9. ARM INTERRUPT Enter IRQ Disable IRQ spsr_irq = cpsr pc = 0x18 IRQ Handler IRQ function Leave IRQ Enable IRQ pc=LR - 4 spsr = spsr_irq 0x00 0x04 0x08 0x0c 0x10 0x14 0x18 0x1C 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  10. 10. SIMPLE RASPBERRY PI BOOT • PI GPU Boot • Black magic(closed source) • GPU, memory, clock initialize • Parse config.txt • Linux Boot • Load cmdline.txt and Linux kernel • Send boot argument to linux kernel • Start from 0x8000 PI GPU Boot Linux Boot: 0x8000 Shell FreeRTO S 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  11. 11. COMPILE A PROGRAM Stage 1 Stage 2 Stage 3 Stage1 • Generate object file Stage 2 • Put object together Stage 3 • Output binary file 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  12. 12. LINKER SCRIPT •Put things to section init, text, data, bss •Assign section address Put init to INIT_RAM: 0 INIT_RAM start: 0x8000 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  13. 13. FREERTOS BOOT _start: Start from 0x8000 Interrupt table 0x8000~0x801C (7 mode) rest: Move interrupt table to 0x0000 Initial interrupt stack 0x0000 … … 0x001C BCM2836 Interrupt Table Memory 0x8000 … … 0x801C FreeRTOS Interrupt Table 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  14. 14. FREERTOS FOR PI2 BOOT •Interrupt failed Hyper mode •Make interrupt work • Go back to SVC 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  15. 15. BCM2836 INTERRUPT BCM2836 Interrupt Controller Peripherals GPIO UAR T TIME R ARM FIQ IRQ Enter IRQ Disable IRQ spsr_irq = cpsr pc = 0x18 IRQ Handler BCM2836 IRQ Controller Handler Leave IRQ Enable IRQ spsr = spsr_irq pc=LR - 4 …. 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  16. 16. FREERTOS PORTING TODO LIST Hardware config: FreeRTOSConfig.h portmacro.h Hardware TIMER IRQ: port.c portISR.c 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  17. 17. FIRST STEP PORTING GPIO • LED • Boot • Linker script UART • Debug Interrupt • Timer IRQ 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  18. 18. BOOT LOADER U-BOOT Debug & Build Power off Put image to SD card Plug in SD Test Debug & Build U-boot tftp get U-boot load Test 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  19. 19. FREERTOS IRQ INTERRUPT Enter IRQ Mode Save Task Timer Handler FreeRTOS tick increase Context switch if needed Leave IRQ Mode Restore Task 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  20. 20. FREERTOS PORTING •Implement Timer Handler • FreeRTOS tick increase • Context switch if needed •Install FreeRTOS as IRQ Handler • Save Task • Restore Task 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  21. 21. FREEROTS PORTING FLOW Develop Environment • IDE • Toolchain • Debug tool Basic knowledge • Boot startup code • Linker script • Interrupt setting Basic drivers • LED • GPIO • Interrupt FreeRTOS • Timer ISR as tick service • FreeRTOS as IRQ handler FreeRTOS Application 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  22. 22. FREERTOS DEMO Basic task communication demo: 1 task send 1 task receive (toggle LED) Application demo: CLI(Command Line Interface) 105 艾鍗科技嵌入式Linux系統工程師人才養成班
  23. 23. Thanks for your attention 105 艾鍗科技嵌入式Linux系統工程師人才養成班

×