1 / 32

MicroC/OS-II

MicroC/OS-II. Chia-Tai Tsai tai@cis.nctu.edu.tw. Feature. Source Code Open Source ,程式碼簡潔易懂 Portable 程式碼大部分皆是利用 ANSI C 所開發的 與 microprocessor 行為有關的則利用組合語言來完成,使得 uC/OS-II 能夠輕易的移植到其他 Processor uC/OS-II 可以在 8/16/32 bits 的 microprocessor 上或是 micro-controller 上運作. Feature. ROMable

conroy
Download Presentation

MicroC/OS-II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MicroC/OS-II Chia-Tai Tsai tai@cis.nctu.edu.tw

  2. Feature • Source Code • Open Source,程式碼簡潔易懂 • Portable • 程式碼大部分皆是利用ANSI C所開發的 • 與microprocessor行為有關的則利用組合語言來完成,使得uC/OS-II能夠輕易的移植到其他Processor • uC/OS-II可以在8/16/32 bits的microprocessor上或是micro-controller上運作

  3. Feature • ROMable • 只要有適當的工具(C compiler, assembler and linker/locator)就可以將uC/OS-II嵌入成為產品一部分 • Scalable • 可以很簡單的選用程式/產品所需要的特性 • 也就是說可以依照自己的需求減少程式的大小,以便可以放入ROM/RAM中

  4. TASK WAITING TASK DORMANT TASK READY TASK RUNNING ISR RUNNING

  5. Feature • Preemptive • uC/OS-II 永遠會讓已經Ready且優先權最高的工作行程先執行 • Multi-tasking • uC/OS-II最多可支援64個task,其中會為系統保留8個task使用 • 每一個task都有一個唯一的priority,也就是說uC/OS-II無法實現Round Robin排程

  6. TASK #n Stack TASK #1 Stack TASK #2 Stack Task Control Block Task Control Block Task Control Block Status Status Status SP SP SP Priority Priority Priority . . . . . . . . . SP . . . …… MEMORY CPU

  7. LOW Priority Task ISR (1) (2) HIGH Priority Task (4) (3) Time ISR makes the high priority task ready (5) (6) (7)

  8. Feature • Deterministic • 在uC/OS-II內的各項服務所需要的執行時間都是可明確預先得知的 • Task Stacks • uC/OS-II允許每一個task擁有不一樣的stack size • 根據需要增減task的stack size減少RAM的使用

  9. Feature • Services • Mailbox, Queues, Semaphores, Fixed-sized memory partitions, Time related function, etc. • Interrupt Management • Interrupts can suspend the execution of a task • 255 levels • Robust and Reliable

  10. uC/OS-II移植分析 • 只要有相對應的C Compiler,即可將uC/OS-II移植到特定的處理器上 • 大部分移植工作都在多任務的切換上 • 用來儲存以及恢復register的值 • 利用組合語言完成 • 需修改的檔案 • OS_CPU.H, OS_CPU_C.C, OS_CPU_A.S

  11. OS_CPU.H • 定義DATA TYPE • 與所使用的Compiler相關 • 不同的Compiler會使用不一樣的byte來表示同一DATA TYPE • X86平台, Integer: • GNU (gcc): 4 bytes • M$ (VC++): 2 bytes

  12. OS_CPU.H • Stack Entry • 定義TASK的Stack長度,必須要和CPU的Resgister的長度一致 • 堆疊增長方向 • 定義Stack grows from HIGH to LOW or Low to HIGH Memory

  13. OS_CPU.H

  14. OS_CPU.H • 中斷、Content Switch

  15. AX CX DX BX SP BP SI DI ES DS OS_CPU_C.C HIGH • Initialize a Task‘s STACK • 在堆疊增長的方向上定每一個需要保存的Register位址 LOW

  16. OS_CPU_C.C

  17. OS_CPU_A.S • OSStartHighRdy( ) • 在OSStart()啟動之後,負責從最高優先權任務的TCB Control Block中獲得該任務的Stack Point(SP) • OSCtxSw( ) • 將前一task的register保存到堆疊中,獲得最高優先權task的SP,將此task的register恢復,使之繼續執行

  18. OS_CPU_A.S • OSIntCtxSw( ) • 中斷級的Content Switch

  19. lwIP簡介 • 一套用於embedded system的TCP/IP • lwIP可以移植到各OS上,在沒有OS情形下也可以獨立運作 • lwIP主要是為了保持TCP Protocol的主要功能並減少對RAM的使用 • 只需要幾十K的RAM和約40K的ROM就可以運作,使得lwIP很適合在嵌入式系統中運作

  20. ULP lwIP Protocol uC/OS-II Network Driver Embedded System系統開發板 NE2000 lwIP簡介

  21. lwIP特性 • IP including packet forwarding over multiple network interfaces • ICMP for network maintenance and debugging • UDP for datagram data • TCP with congestion control, RTT estimation and fast recovery/fast retransmit • Specialized no-copy API for enhanced performance • Optional Berkeley socket API

  22. lwIP將所有與硬體、OS、Compiler相關的部分獨立出來放置在/src/arch下lwIP將所有與硬體、OS、Compiler相關的部分獨立出來放置在/src/arch下 • 修改這一些相關檔案將lwIP移植到uC/OS-II上

  23. eth_addr eth_hdr ip_addr ip_hdr pbuf tcp_hdr tcp_pcb tcp_seq udp_hdr udp_pcb lwIP Data Structure

  24. lwIP Data Structure • eth_addr • The structure of one MAC address • eth_hdr • eth_addr dest • eth_addr src eth_addr eth_hdr

  25. lwIP Data Structure • ip_addr • The structure of a IP address in network byte order • ip_hdr ip_addr ip_hdr

  26. lwIP Data Structure • pbuf • The header structure of packet buffers • A pbuf is lwIP’s internal representation of a packet • Designed for the special needs of the minimal stack • similar to the mbuf used in the BSD implementations

  27. lwIP Data Structure • Allocating dynamic memory to hold packet contents • Letting packet data reside in static memory • Pbufs can be linked together in a list

  28. lwIP Data Structure • tcp_hdr • The header of a TCP packet • tcp_pcb • The protocol control block for TCP connections • contains any information for one TCP connection

  29. lwIP Data Structure • The TCP PCBs are kept on a linked list which is searched for a match when a TCP packet arrives • TCP PCB structures contain a pointer to the next PCB in the global linked list of TCP PCBs

  30. lwIP Data Structure • tcp_seq • This structure is used to represent TCP segments when queued

  31. lwIP Data Structure • udp_hdr • the header of a UDP packet • udp_pcb • The protocol control block for UDP connections • contains any information for one UDP connection

  32. lwIP Data Structure • UDP PCBs are kept on a linked list which is searched for a match when a UDP datagram arrives • UDP PCB structures contain a pointer to the next PCB in the global linked list of UDP PCBs

More Related