1 / 105

Presenter:Wytai

IEOS : uC/OS-II Porting. Presenter:Wytai. Date:. Outline. Introduction General Porting ARM Intel. Introduction. Embedded system 需要什麼樣子的功能 需要什麼樣子的硬體 是否需要作業系統 何時可以完成開發 價格 ( 成本 ) 維護和升級的考量. Introduction. Embedded system OS NON-OS ( 看影片 ). Introduction. NON-OS embedded system.

alika
Download Presentation

Presenter:Wytai

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. IEOS:uC/OS-II Porting Presenter:Wytai Date: /105

  2. Outline • Introduction • General Porting • ARM • Intel /105

  3. Introduction • Embedded system • 需要什麼樣子的功能 • 需要什麼樣子的硬體 • 是否需要作業系統 • 何時可以完成開發 • 價格(成本) • 維護和升級的考量 /105

  4. Introduction • Embedded system • OS • NON-OS (看影片) /105

  5. Introduction • NON-OS embedded system /105

  6. Introduction /105

  7. Introduction • Embedded system with OS /105

  8. Embedded OS • RTOS • uC/OS-II • uCLinux • Embedded Linux • Vxworks • Palm • WinCE /105

  9. Embedded OS • 新華提供 • 1. 易於快速完成開發(公司外部支援或內部能力) • 2. 作業系統需要與否 • 3. 價格(open source 或是商用) • 4. 維護、升級方便否 • 5. 系統大小而採不同大小的作業系統之考量 • 6. 各種 Utilities, Driver, Stack 提供完整否 • 7. 不用考慮,因跟著 Turn key solution /105

  10. Embedded OS /105

  11. uC/OS-II • uC/OS-II • Preempt RTOS by priority • Jean J. Labrosse • 1992 uC/OS • 1999 uC/OS-II • 2000 RTCA DO – 178B (Federal Aviation Administration) /105

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

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

  14. TASK WAITING TASK DORMANT TASK READY TASK RUNNING ISR RUNNING /105

  15. Feature • Preemptive • uC/OS-II 永遠會讓已經 Ready 且優先權最高的工作行程先執行 • Multi-tasking • uC/OS-II 最多可支援 64 個 task,其中會為系統保留 8 個 task使用 • 每一個 task 都有一個唯一的 priority /105

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

  17. Feature • Services • Mailbox, Queues, Semaphores, Fixed-sized memory partitions, Time related function, etc. /105

  18. uC/OS-II /105

  19. uC/OS-II Porting Limit • Hardware limit • 處理器的 C 編譯器能產生可重入程式碼。 • 用 C 語言就可以打開和關閉中斷。 • 處理器支援中斷,並且能產生定時中斷 (通常在 10 至 100Hz 之間)。 • 處理器支援能夠容納一定數量的資料的硬體堆疊 (可能是幾千位元組)。 • 處理器有將堆疊指標和其他 CPU 暫存器讀出和存儲到堆疊或記憶體中的指令。 /105

  20. uC/OS-II porting • 1. 裝置啟動後,執行完硬體的初始設定或是硬體狀態檢查,就直接跳轉到 AP 執行的位置 • 2.uC/OS-II 一般啟動流程 main OSInit OSStartHigeReady OSTimeTickInit OSStart Task create Do something Task 1 OSStatrt TimeDly Context switch Other Tasks /105

  21. uC/OS-II Porting • Porting = bootloader + OS • Bootloader • Initialize hardware, vectors, memory, stack, register value • There are two ways • 分開成兩個檔案(bin),bootloader裡面要設定OS Image存放的位址(OS入口),需要兩者一致方可成功啟動OS • 合成一個bin檔,在bootloader執行完以後,透過跳轉__main進入OS入口 • … /105

  22. uC/OS-II Porting • Tftp xxxx uImage • Bootm xxxx /105

  23. Solution 1 OS (image) Bootloader (image) /105

  24. uC/OS-II Porting • Open source • Bootloader : Uboot • OS : GCC • SDT (Software Development Kit) • ADS (ARM Development Suite) • RDVS (RealView Developer Suite ) • Borland C 、VC、Keil • Other hardware dependent compiler /105

  25. uC/OS-II Porting • Preparation • uC/OS-II source code http://www.micrium.com/ • V.2.86 • Porting file http://www.micrium.com/ • V.1.50 • Cross compiler choose • Hardware • Hardware Spec • Compiler Spec • (ARM) assembly knowing /105

  26. BootLoader /105

  27. Introduction • U-boot • Bootloader • Depend on CPU • Stage1 – ASM • Initial Hardware • Disable interrupt • Set CPU speed and clock rate • RAM • LED (GPIO) • Hardware driver • Set Stack • Set RAM for Stage2 • Copy Stage2 to RAM • Go to Stage2 /105

  28. Introduction • Stage2 – C ( most checking) • Initial COM • Initial timer • Check memory map • Copy Kernel from flash to RAM • Image size (base and end address) • Take kernel image /105

  29. Related work • README in u-boot • Datasheet • lowlevel_init.S in /board/boardname /105

  30. Uboot /105

  31. Uboot /105

  32. Porting Steps • mkdir boardname in /board/ • Find a similar board in u-boot • Copy all files to the new directory • Change files name to appropriate name(boardname) • Add boardname.h in /include/configs/ • Refer to README • Lubbock is similar to XSBase255 /105

  33. Porting Steps • Boardname.h • #Undefine CONFIG_USE_IRQ • #define CONFIG_CPUName • #define CONFIG_Boardname • #define CFG_CPUSPEED 0x00000161 • #define CFG_HZ 3686400 /105

  34. Porting Steps • Size of malloc() pool • #define CFG_MALLOC_LEN value • memory settings • #define CFG_MSC0_VAL 0x7FF87FF0 • #define CFG_MSC1_VAL 0x12BC5554 • #define CFG_MSC2_VAL 0x7FF87FF1 • #define CFG_MDCNFG_VAL 0x00001AC9 • #define CFG_MDREFR_VAL 0x000BC018 • #define CFG_MDMRS_VAL 0x00000000 /105

  35. Porting Steps • physical memory map • #define CONFIG_NR_DRAM_BANKS 4 • #define PHYS_SDRAM_1 0xA0000000 • #define PHYS_SDRAM_1_SIZE 0x04000000 • #define PHYS_SDRAM_2 0xA4000000 • #define PHYS_SDRAM_2_SIZE 0x00000000 • #define PHYS_FLASH_1 0x00000000 • #define PHYS_FLASH_2 0x04000000 • #define CFG_DRAM_BASE 0xA0000000 • #define CFG_DRAM_SIZE 0x04000000 /105

  36. Porting Steps • #define CONFIG_LED 1 • GPIO settings • #define CFG_GPSR0_VAL 0x00408030 • #define CFG_GPSR1_VAL 0x00BFA882 • #define CFG_GPSR2_VAL 0x0001C000 • #define CFG_GPCR0_VAL 0xC0031100 • #define CFG_GPCR1_VAL 0xFC400300 /105

  37. Porting Steps • Hardware Driver • #define CONFIG_DRIVER_CS8900 1 • #define CS8900_BUS16 1 • #define CS8900_BASE 0x04000300 • stack size • #define CONFIG_STACKSIZE (128*1024) /105

  38. Porting Steps • #define KERNEL_SRAM_BASE address • #define KERNEL_DRAM_BASE address • #define KERNEL_MAX_SIZE your decision • Load kernel image • ldr r4, =KERNEL_SRAM_BASE • ldr r5, =KERNEL_DRAM_BASE • ldr r6, =KERNEL_MAX_SIZE • add r6, r6, r4 • repeat1: • ldmia r4!,{r0-r3,r7-r10} • stmia r5!,{r0-r3,r7-r10} • cmp r4, r6 • blt repeat1 /105

  39. Porting Steps • Cmd_boot.c • Cmd_bootm.c /105

  40. Porting Steps • Modify u-boot makefile • Boardname_config : unconfig • @./mkconfig $(@:_config=) CPUtype CPUname boardname • Xsbase_config : unconfig • @./mkconfig $(@:_config=) arm pxa xsbase • Modify u-boot makeall • LIST_CPUname = “ add boardname ” • LIST_pxa = “ adsvix csb226 lubbock pxa255_idp • xaeniax xm250 xsengine xsbase “ /105

  41. Porting Steps • Make image • Make board_config • Make all • Make sure cross compiler • It will generate u-boot.bin /105

  42. Uboot /105

  43. Uboot /105

  44. Uboot /105

  45. ARM /105

  46. ARM • 7 CPU Mode • Usr mode • Sys mode • Svc mode • Irq mode • Fiq mode • Abt mode • Und mode /105

  47. ARM • Usr mode • User mode : 使用者模式 • ARM微處理器正常的程式執行狀態 • Sys mode • Systwm mode : 系統模式 • 執行具有特權的作業系統任務 /105

  48. ARM • SVCmode • Supervisor mode : 管理者模式 • 作業系統使用的保護模式 • Irq mode • Interrupt request mode : 外部中斷模式 • 用於通用的中斷處理 /105

  49. ARM • Fiq mode • Fast interrupt request mode : 快速中斷模式 • 應用於高速資料傳輸或通道處理 • Abt mode • Abort mode : 中止模式 • 當資料或指令預取終止時進入該模式,可用於虛擬儲存及儲存保護 • Und mode • Undefined mode : 未定義指令中止模式 • 當未定義的指令執行時進入該模式,可用於支援硬體輔助運算器的軟體除錯 /105

  50. ARM • 一般(通用)暫存器 :31個 (R0~R15) • 不同的 CPU mode 可以存取的暫存器略有不同 • R0~R7: share • R8~R12 : fiq mode 有自己的 • R13,R14(sp,lr) : each mode 都有自己的一份,但是 usr 和 sys 共用 • R15 = PC : only one /105

More Related