SlideShare a Scribd company logo
1 of 102
Download to read offline
探索嵌入式 ARM 平台與 SoC
           Part I – ARM 架構瀏覽 .SoC 平台 . 關鍵概念

                                              Jim Huang (jserv)
                                                 from 0xlab

                                                June 20, 2010



                                                                  1
0xlab – connect your device to application – http://0xlab.org/
Rights to copy
                                                                 © Copyright 2009­2010 0xlab.org
                                                                               contact@0xlab.org
                                                                  Corrections, suggestions, contributions and 
                                                                                   translations are welcome!

   Attribution – ShareAlike 3.0
   You are free
      to copy, distribute, display, and perform the work
      to make derivative works
      to make commercial use of the work
   Under the following conditions
         Attribution. You must give the original author credit.
         Share Alike. If you alter, transform, or build upon this work, you may distribute the 
         resulting work only under a license identical to this one.
      For any reuse or distribution, you must make clear to others the license terms of this 
      work.
      Any of these conditions can be waived if you get permission from the copyright holder.
   Your fair use and other rights are in no way affected by the above.
   License text: http://creativecommons.org/licenses/by­sa/3.0/legalcode                                         2
0xlab – connect your device to application – http://0xlab.org/
切入點

           從軟體開發者的角度檢視 ARM 架構
           善用開放原始碼軟體
            GNU Toolchain – CodeSourcery 2009q1
                QEMU 0.12.3
                CuRT v1 ( 土製 ARM 即時作業系統 )
           參考 ARM SoC 平台: Marvell/Intel PXA255
           作中學:觀察、系統模擬、驗證,動手


                                                                 3
0xlab – connect your device to application – http://0xlab.org/
Agenda

           ARM 架構快速瀏覽
           ARM SoC 平台
           關鍵概念:
                工作模式、暫存器組、系統狀態、指令集、
                例外處理




                                                                 4
0xlab – connect your device to application – http://0xlab.org/
ARM 架構快速瀏覽
                ARM 歷史背景
                ARM 的「家族」
           ARM SoC 平台
           關鍵概念:
                工作模式、暫存器組、系統狀態、指令集、例外處理




                                                                 5
0xlab – connect your device to application – http://0xlab.org/
Part I 涵蓋範圍   6
0xlab – connect your device to application – http://0xlab.org/
無所不在的 ARM




                                                                 7
          Most of the above devides are powered by ARM.
0xlab – connect your device to application – http://0xlab.org/
Darwin's Concept


                                                                 適者生存




                                                                        8
0xlab – connect your device to application – http://0xlab.org/
在 ARM 之前
          BBC Micro (BBC Microcomputer System) 在 BBC (Britsh 
          Broadcasting Corporation) 主導的 BBC Computer Literacy 
          Project 中,設計一系列的電腦與週邊裝置。於 1980 年代已有
          顯著的技術突破
               《 The Computer Programme 》 , 1982
                programming, graphics, sound and music, Teletext, 
               controlling external hardware and artificial intelligence

          ( 對 BBC Micro 的 ) 電腦供應商 Acorn Computers 升級其
          Atom microcomputer 設計,是為 Proton ,提供更佳的圖形處
          理與更快的 2 MHz MOS Technology 6502 CPU
          1982 年,競爭對手 Sinclair 推出 ZX Spectrum ,嚴重威脅
          Acrom 獲利

                                                                           9
0xlab – connect your device to application – http://0xlab.org/
ARM 就此展開
         1983­1985 年間, Acorn Computers 推出第一款 ARM chip ,即
         Acorn RISC Machine 。爾後該設計團隊於 1990 年代分後,公司命
         名為 “ Advanced RISC Machine” (ARM)
         成功取代 6502 processor 市場

         ARM1 –  由 VLSI Technology, Inc. 製造晶圓生產 (1985) 
         ARM2 –  量產 (1986)
           32­bit data bus, 26­bit address space (top 6 bits used as status flag)
           16 32­bit registers (1 PC), 30,000 transistors
           No microcode, cache, Low power
         國家半導體 NS 32016 的出現,威脅 Acorn 的獲利模式,隨後引發
         財務危機, 1985 年,義大利設備商 Olivetti Ing et Cie 入主
         ARM3 –  引入 4KB Cache, 25MHz (1989­1990)
                                                                               10
0xlab – connect your device to application – http://0xlab.org/
ARM1 Architect

          Steve Furber
          Roger Wilson
          Robert Heaton


                                                                    Steve Furber
                                                              sfurber@cs.man.ac.uk
                                                                   Father of ARM




                                                                                     11
0xlab – connect your device to application – http://0xlab.org/
ARM Ltd. 出現

     1990 年代, Acorn 的財務狀況趨於穩定,亟欲轉型。該年
     底,於英國劍橋,由 Apple, Acorn, VLSI 三家公司共同成立
     ARM Ltd.
     ARM Ltd. 成立後,將 ARM3 的下一代命名為 ARM6 ,實體裝
     置為 ARM600
     稍候的 ARM610 用於 Apple Newton PDA(­1998)

     1992 年底, 3DO 公司 ( 主要產品:遊戲機 ) 自 ARM Ltd. 取得
     ARM 授權並成功量產電子設備,自此, ARM 在出售晶片設計
     技術授權,獲得成功
     目前採用 ARM 技術知識產權 (IP) 核心的微處理器,即我們常
     所說的 ARM 微處理器
     ARM 遍及工業控制、消費性電子產品、通信網路系統等領域
     ARM7TDMI 是早期成功的 ARM core ,出貨量達數億單位

                                                                 12
0xlab – connect your device to application – http://0xlab.org/
ARM7TDMI 是早期成功的 ARM core ,出貨量達數億單位

                                               StrongARM     ARM9,920
MIPS
 100


   80
                                        ARM8,810
   60
                                        ARM7TDMI
                          ARM7D,7DM
   40

                  ARM7,710
                                  ARM Ltd. 成立後,將 ARM3 的下一代命名為 ARM6 ,
   20
            ARM6,60,610           實體裝置為 ARM600 。稍候的 ARM610 用於 Apple 
   0
        ARM2,3                    Newton PDA(­1998)
        1985 - 90 1991    1992   1993   1994      1995     1996   1997
                                                                         13
0xlab – connect your device to application – http://0xlab.org/
ARM 的 SWOT 分析

      由 1990 年 12 月 18 日 ( 時值 ARM Ltd. 成立 21 日 )
      的內部文件,評估企業的 SWOT
        Strengths: 優勢
           Weaknesses: 劣勢
           Opportunities: 競爭市場的機會
           Threats: 威脅




                                                                 14
0xlab – connect your device to application – http://0xlab.org/
15
0xlab – connect your device to application – http://0xlab.org/
ARM 的時代

          DEC 自 ARM Ltd. 取得 ARM6 的授權,依據此基礎研發出
          時脈可達 233MHz 的 StrongARM (SA­1x 系列 )
            使用於 PDA 裝置,如 HP iPAQ
               500 mWatt of power @160MHz @.35µm
          DEC 後來為了與 Intel 控訴和解,將技術移轉到 Intel (1997)
          Intel 依據 StrongARM 的基礎,發展出 Xscale 
          StrongARM 關鍵的成員出走 Intel 後,成立 P.A. Semi 
          (Palo Alto Semiconducto)(2003) ,爾後被 Apple 併購 (2008)
          Intel 出售 XScale 產品線予 Marvell (2006)



                                                                 16
0xlab – connect your device to application – http://0xlab.org/
Dan Dobberpuhl
                                                    Father of Alpha, StrongARM



                                                                                 17
0xlab – connect your device to application – http://0xlab.org/
ARM 的「家族」

          Architecture Versions
             ARM V3, V4, V5, V6, V7
               使用 “ architecture” 一詞標注硬體設計架構
                     更具體來說,指的是 ISA (Instruction Set Architecture)


          Implementations ( 涉及不同的製程 )
               ARM6 (1991), ARM7 (1995), ARM9 (1997)
               ARM10 (1999), ARM11 (2003)
               使用 “ cores” 一詞標注其世代演進




                                                                    18
0xlab – connect your device to application – http://0xlab.org/
19
0xlab – connect your device to application – http://0xlab.org/
Application Note – Core Type &
                  0x41 A (ARM Ltd)   Revision Identification, ARM
                  0x44 D (DEC)
                  0x69 I (Intel Corporation)
                                                               Architecture
/ # cat /proc/cpuinfo
/ # cat /proc/cpuinfo                                            version
Processor
Processor       : ARMv7 Processor rev 3 (v7l)
                : ARMv7 Processor rev 3 (v7l)
BogoMIPS
BogoMIPS        : 471.61
                : 471.61
Features
Features        : swp half thumb fastmult vfp edsp thumbee neon
                : swp half thumb fastmult vfp edsp thumbee neon
CPU implementer : 0x41
CPU implementer : 0x41
CPU architecture: 7
CPU architecture: 7
CPU variant
CPU variant     : 0x1
                : 0x1
CPU part
CPU part        : 0xc08
                : 0xc08                             ARM ISA feature
CPU revision
CPU revision    : 3
                : 3

Hardware
Hardware                     :
                             :   OMAP3 Beagle Board
                                 OMAP3 Beagle Board
Revision
Revision                     :
                             :   0020
                                 0020
Serial
Serial                       :
                             :   0000000000000000
                                 0000000000000000



          採用 ARM 技術知識產權 (IP) 核心的微處理器,即我們
          常所說的 ARM 微處理器,實際的組態變化相當多元
                                                                                                  20
0xlab – connect your device to application – http://0xlab.org/
ARMv1

          Implementation: 僅在原型機 ARM1 出現
          指令集:
            基本的資料處理指令 (ALU) ,不包含乘法指令
               Byte, half­word, word 的 Load/Store 指令
               跳躍 (jump/branch) 指令,包括 procedure call
               軟體中斷 (SWI) 指令
               定址空間: 64MB




                                                                 21
0xlab – connect your device to application – http://0xlab.org/
ARMv2

               Implementation: ARM2 與 ARM3 (ARMv2a) 等硬體
               指令集:
                     增加乘法和乘加指令
                     支援輔助運算器操作指令
                     快速中斷模式 (FIQ)
                     SWP/SWPB 的最基本記憶體與暫存器交換指令
                    定址空間: 64MB (32­bit data bus, 26­bit address 
                    space (top 6 bits used as status flag)




                                                                   22
0xlab – connect your device to application – http://0xlab.org/
ARMv2 :: SWP

        在 ARM 暫存器組交換一個 word
              Two cycles
                                                                 R0
        並確保
                                                                 R1
        single atomic action                                     R2
              Support for RT semaphores
                                                                 R7
                                                                 R8


                                                                 R15




                                                                       23
0xlab – connect your device to application – http://0xlab.org/
ARMv3
                                   較大的改動,將定址空間增至 32­bit (4GB) 。
                                   追加 CPSR 和 SPSR ,以利異常處理。增加
                                   中止和未定義等兩種處理器模式
                                   Implementation: ARM6
                                   裝置範例: Apple Newton PDA
                                   指令集:
                                        增加 MRS/MSR 指令,存取新增的
                           Mi
               LDM                      CPSR/SPSR 暫存器       R0
                           Mi+1
    R0                     Mi+2         增加從異常處理返回的指令功能                        R1
    R1                                                                  MRS
    R2                                                                        R7
                           Mi+14
                                                                 CPSR   MSR   R8
                           Mi+15
   R14                                                           SPSR
              STM
   R15                                                                        R14   24
0xlab – connect your device to application – http://0xlab.org/                R15
ARMv3 :: Memory Addressing
                                                            Byte : 8 bits
 alignment 相當重要,一些隱性的                                       Halfword : 16 bits
陷阱可參考拙作〈我是軟體,那些                                                  must be aligned to 2­byte boundaries
處理器教我的事〉 (COSCUP 2008)                                      Word : 32 bits
                                                                 must be aligned to 4­byte boundaries
      bit 31                  bit 0                         ARM address can be 32 bits long.
                                                            Address refers to byte.
   23         22         21        20                            Address 4 starts at byte 4.
                                                            可在系統啟動時,調整為 little­ or 
   19         18         17        16                       big­endian mode
               word16
                                                                    bit 31     little­endian      bit 0
   15         14         13        12
 half-word14 half-word12
                                                                     byte 3 byte 2 byte 1 byte 0
   11         10         9          8
                word8
    7          6         5          4
           byte6 half-word4                                       bit 0        big­endian       bit 31
                                                       byte
                                                       address byte 0 byte 1 byte 2 byte 3
    3          2         1          0
 byte3 byte2 byte1 byte0
                                                                                                        25
0xlab – connect your device to application – http://0xlab.org/
ARMv4

               廣泛應用的 ARM 架構,對 ARMv3 作進一步擴充,引入引
               進了 16­bit Thumb 指令集 ( 可選擇 )
               Implementation: ARM7, ARM9, StrongARM
               裝置範例: GameBoy Advance, Nintendo DS, iPod, LEGO 
               NXT, Openmoko GTA01/GTA02
               指令集:
                     增加 16­bit Thumb 指令集
                     加強軟體中斷 (SWI) 指令的功能
                    處理器系統模式引進特權方式 (SVC) 時,以 user 暫存
                    器操作
                    將未使用的指令空間,捕捉為未定義指令

                                                                 26
0xlab – connect your device to application – http://0xlab.org/
ARMv4
               從 bus­structure 的角度來看 ARMv4 的 Implementation
                     ARM7 : von Neumann architecture
                     ARM9 : modified Harvard architecture




                                                                 27
0xlab – connect your device to application – http://0xlab.org/
ARMv4 :: ARM/Thumb
             32­bit ARM Instruction 
             Sets
             16­bit Thumb Instruction 
             Set
                   更高的指令集密度
                   對 cache 處理更有效率
             All instructions are 
             executed as ARM
             Decompressor converts 
             Thumb to equivalent ARM 
             instruction
             Decompressor present in 
             the decode stage of the 
             pipeline.

                                                                 28
0xlab – connect your device to application – http://0xlab.org/
ARMv5

              Implementation: ARM10, Xscale
              裝置範例: HTC Dream (Google G1 Phone)
              指令集:
                    BLX 指令 (Improved ARM and Thumb interworking)
                    CLZ 指令 (count leading­zeroes)
                    BRK 中斷指令
                    增加 DSP 強化指令 (v5TE)
                        E – enhanced DSP instructions including saturated arithmetic 
                        operations and 16­bit multiply operations
                    增加 Jazelle 指令集
                        J – support for new Java state, offering hardware and 
                        optimized software acceleration of bytecode execution.
                    為 co­processor 增加更多可選擇的指令                                     29
0xlab – connect your device to application – http://0xlab.org/
ARMv5 :: DSP Extension (E)




                                                                 30
0xlab – connect your device to application – http://0xlab.org/
ARMv5 :: co­processor

       Marvell/Intel Xscale Wireless MMX co­processor
            概念:將 x86 行之有年的 MMX/SSE 指令集設計概念,應用於 Xscale 處理
            器,以 co­processor 的形式存在
       ARM 的架構最多可支援 16 個 co­processor ,以 Xscale 為例:
         co­processor 0
            co­processor 1
       Xscale co­processor instructions
          Coprocessor data transfers
            Coprocessor data operations
            Coprocessor register load and store


                                                                 ARM
                                                                        Co-processor
                                                                 Core



                                                                                       31
0xlab – connect your device to application – http://0xlab.org/
ARMv6

               Implementation: ARM11
               裝置範例: Apple iPhone (1st/2nd)
               指令集 / 特性:
                    引入 60 個以上新的 SIMD(Single Instruction Multiple 
                    Data) ,使多媒體處理速度快 1.75 倍
                     提出新的 atomic operations(LDREX/STREX)
                      避免 swp 指令的限制
                     改進記憶體管理,使系統性能提高 30%
                    強化 Mixed­Endian 支援 (Little­Endian OS + Bit­Endian 
                    Data for TCP/IP)
                     改進 unaligned data 支援,進一步提昇字串操作的效能
                                                                    32
0xlab – connect your device to application – http://0xlab.org/
ARMv6 :: SIMD Extensions




                                                                 33
0xlab – connect your device to application – http://0xlab.org/
ARMv6 :: Endianness Support (E bit)




                                                                 34
0xlab – connect your device to application – http://0xlab.org/
ARMv6 :: Byte Reverse instruction




                                                                 35
0xlab – connect your device to application – http://0xlab.org/
ARMv6 :: unaligned access




   Test on BeagleBoard 500 MHz + 0xdroid (0xlab's Android distribution)
  mmemcpy_use_unaligned :  (16 bytes copy) =  167.4 MB/s /  368.7 MB/s
  memcpy :                 (16 bytes copy) =  137.0 MB/s /  352.5 MB/s

  mmemcpy_use_unaligned :  (24 bytes copy) =  231.3 MB/s /  552.7 MB/s
  memcpy_neon :            (24 bytes copy) =  199.3 MB/s /  350.5 MB/s

  mmemcpy_use_unaligned :  (31 bytes copy) =  315.6 MB/s /  714.2 MB/s
  memcpy :                 (31 bytes copy) =  267.9 MB/s /  375.6 MB/s

                                                                         36
0xlab – connect your device to application – http://0xlab.org/
ARMv7

         Implementation: Cortex­A8
            第一個 ARMv7 ISA 的完整 implementation ,包含 Advanced 
            SIMD Media Extension (NEON)
            自 ARMv7 起, core 命名改以 Cortex 開頭
         In­order, dual­issue superscalar core
            13­stage integer pipeline
            10­stage NEON media pipeline
            Dedicated L2 with 9­cycle latency
            Branch predictor based on global history
            NEON: 64/128­bit SIMD, 2x­4x ↑ over prior ARMv6 SIMD
         ARMv7 關鍵特性
            引入 Thumb­2, Thumb­EE (for dynamic/JIT compiler)
         對應的 Implementation 時脈達 1 GHz
              功耗小於 300mW
              <  4mm2 at 65nm ( 不含 NEON, L2 cache, ETM)
                                                                   37
0xlab – connect your device to application – http://0xlab.org/
    Source: Williamson of ARM at Fall processor Forum 05
ARMv7 :: NEON

        64/128­bit 混合式 SIMD 架構                                              D0
                                                                                         Q0
                                                                            D1
        Two aliased register files                                          D2
                                                                                         Q1
            32 x 64­bit (D0­D31)                                            D3

            16 x 128­bit (Q0­Q15)
            Shared with VFP
                                                                           D30
        Integer and SP FP processing                                       D31
                                                                                        Q15

          8, 16, 32, 64­bit integers
        Encoded in ARM and Thumb­2                               Alias, same physical structure

                                                                           64­bit
                                               D1.U8                                  D0.U8
                                                                                      Q0.F32
                                                                 128­bit



                                                                                               38
0xlab – connect your device to application – http://0xlab.org/
    Source: Grisenthwaite of ARM
vadd.I16 D0, D1, D2                                 vmul.I32.S16 Q0, D2, D3
                                        D1                                                  D2
                                        D2                                                  D3

                +     +     +      +                                   *   *        *   *
                                        D0                                                       Q0
                          64b                                                  128b



                                       vshr.I16.I32 D0, Q1, #5

                                                      128b
                                                                               Q1

                                                                           #5
                                              >> >> >> >>
                                                                  D0
                                                                                                      39
0xlab – connect your device to application – http://0xlab.org/
    Source: Grisenthwaite of ARM
NEON Load or store 1­element or 2, 3, 4­elelment structure
          Handle complex number, coordinates, etc.
          Easy AoS to SoA



        X0        vld3.16 {D0, D1, D2}, [R0]!
        Y0                                                       X3   X2   X1   X0   D0
        Z0
                                                                 Y3   Y2   Y1   Y0   D1
        X1
        Y1                                                       Z3   Z2   Z1   Z0   D2
                  vst3.16 {D0, D1, D2}, [R0]!
        Z1

    • No data swizzling needed!
    • Fewer instruction, higher performance



                                                                                          40
0xlab – connect your device to application – http://0xlab.org/
ARMv7 :: Thumb­2

          大幅改進 Thumb 指令集的限制
           Thumb 的空間使用
           ARM 的效能
          引入混合 16­/32­bit 指令集的並存模式
          不再需要繁瑣的狀態轉換
           兼顧效能與程式碼密度




                                                                      41
0xlab – connect your device to application – http://0xlab.org/   41
ARM core performance roadmap
                                                                                  ARM Cortex
                             Release                                        “Intelligent Computing”
                             Adv Development

            2500



            2000
                                                                                  Cortex­A8 "Tiger" 


            1500
    DMIPS




            1000


                                                                  x4
             750
                                          ARM1176JZF­S™            ARM11 MPCore
                    ARM1136EJ­S™
             500
                                 ARM1026EJ­S™

            250          ARM926EJ­S™


                                       Pre­2005                  2005               2006
   Source: Williamson of ARM at Fall processor Forum 05
                                                                                                       42
0xlab – connect your device to application – http://0xlab.org/
Cortex­A8 NEON Performance

 • Cortex­A8 NEON performance vs. ARMv5 and ARMv6 implementations
                                        1x                    2x                   3x                   4x

  MPEG­4                
  GSM­AMR               
  MP3 Decoder           
                                                       ARM926EJ­S            ARM1136J­S            Cortex­A8    
                                                        ARMv5TE                ARMv6                NEON



  • CPU bandwidth required for various applications:
     – MPEG4 VGA decode1                                                                   275 MHz
     – MP3 decode, 320kbps 48kHz, worst case2                                               
                                                                                             9.8 MHz
     – “Quake 2­like” application, CIF resolution3                                         300 MHz
     – H.264 (estimated)                                                                   350 MHz


  1) MPEG­4 Simple Profile @ 30fps 512kbps , 133MHz SDRAM 10­1­1­1 memory
  2) MP3 Decoder @ 320kbps 48kHz (worst case means cold start on context switch), 133MHz SDRAM 10­1­1­1 memory
  3) Quake2­like simulator, full software graphics pipeline, FP implementation 133MHz SDRAM 10­1­1­1 memory
  Source: ARM Developer conference                                                                                 43
0xlab – connect your device to application – http://0xlab.org/
44
0xlab – connect your device to application – http://0xlab.org/
ARM 架構快速瀏覽
           ARM SoC 平台
           關鍵概念:
                工作模式、暫存器組、系統狀態、指令集、例外處理




                                                                 45
0xlab – connect your device to application – http://0xlab.org/
SoC (System­on­Chip)
       整合多種不同功能的複雜 IC 組合,針對特定的市場或應用需求
       典型的組成
            Programmable processor
            On­chip memory
            HW accelerating function units (DSP)
            Peripheral interfaces (GPIO)
            Embedded software




                                                                 46
0xlab – connect your device to application – http://0xlab.org/
典型的硬體介面
      I/O 裝置藉由 memory­mapped register 溝通
      DMA 與 interrupt 是選擇性的
                                                                                    other
                                                                                    devices
        Memory
                                  I/O device               I/O device



                                                                              Interrupt
Databus                                                                       controller
                                                           Address bus


                                        Direct Memory
     CPU                                Access (DMA)
                                        Controller
      IRQ           FIQ                                           other devices

                                                                                           47
0xlab – connect your device to application – http://0xlab.org/
CPU 與 I/O
       典型有兩種對應方式:
        I/O mapped I/O
                  I/O 與 memory 均擁有自己的記憶體空間
                  需要特別的指令來處理 I/O
            Memory mapped I/O
                  I/O 與 memory 共用記憶體空間
                  不需特別指令來處理 I/O




                                                                 48
0xlab – connect your device to application – http://0xlab.org/
Memory­Mapped I/O
                      FFFF                                       FFFF
                                  Memory                                  I/O
                           0                                       0
                                 R1=1234
                                 sta r0,r1             ;; 寫入 mem address 1234
                                 out r0,r1             ;; 寫入 I/O address 1234
                                                                                2345
                                      FFFF
                                                                        FDD
                                      2345
                                                                         HD
                                                     I/O                LCD
                                     1234                                 .
                                                                          .
                                              0                               1234
                       R0=‘A’, R1=1233, R2=1234 ( 假設 1234 為 LCD 的 MMIO 位址 )
                       str r0, [r1,#0]  ;;addr 1234 =‘A’
                       str r0, [r2,#0]  ;;LCD 顯示‘ A’                                   49
0xlab – connect your device to application – http://0xlab.org/
SoC  實例




                                                                 50
0xlab – connect your device to application – http://0xlab.org/
Display Driver IC: TFT, OLED
                                                       Camera Chipset: CMOS - CCD
                                                       Connectivity: WLAN, GPS, Bluetooth
                                                       Processor: ARM
                                                       Modem: GSM/GPRS, WCDMA
                                                                                      SoC
                                                       RF/Analog: Rx/Tx, Zero IF
                                                       RAM: Mobile DRAM, SRAM, UtRAM
                                                       Smart Card: SIM
                                                       SIP / MCP
                                                       Flash Memory: Code/Data Storage



                                                                                            51
0xlab – connect your device to application – http://0xlab.org/
Modem Chip Evolution for Cellular Phone




                                                                 52
0xlab – connect your device to application – http://0xlab.org/
Moble station :: Baseband




                                                                 53
0xlab – connect your device to application – http://0xlab.org/
Moble station :: Software



                    WAP
                                    Applications (GVM, Wavelet, M-Commerce, LBS..)
                  Browser



                  G-APIs                           Mobile Platform                       T-APIs



                                                                  Protocol         Radio Comm.
                            APP Manager
                                                                   Stack             Interface



                        I/O Device Driver                        Radio Telephony Device Control
                      (HW Abstraction Layer)                       (CDMA/GSM/GPRS/WCDMA)

                                               Embedded OS (REX, VxWorks, Symbian)

                                                     Embedded HW
                                                                                                  54
0xlab – connect your device to application – http://0xlab.org/
ARM On­Chip Bus



                                                On­Chip
                          ARM Core               RAM                      UART                PIO

                                      AHB/ASB                                          APB
         Memory 
                                                                 Bridge
         Interface

                                           DMA
                                          Master                          Timer              Keypad

                                                                          A typical AMBA system



                               AHB: Advanced High-performance Bus
                               ASB: Advanced System Bus
                               APB: Advanced Peripheral Bus

                                            ** AMBA: Advanced Microcontroller Bus Architecture
                                                                                                      55
0xlab – connect your device to application – http://0xlab.org/
Example: GPRS Phone




                                                                 56
0xlab – connect your device to application – http://0xlab.org/
Example: Videophone




                                                                 57
0xlab – connect your device to application – http://0xlab.org/
ARM 架構快速瀏覽
                ARM 歷史背景
                ARM 的「家族」
           ARM SoC 平台

           關鍵概念:
            工作模式、暫存器組、系統狀態、指令
            集、例外處理
            探討 PXA255 SoC 為例
                      觀察 CuRT 的運作並驅動 UART 裝置
                                                                 58
0xlab – connect your device to application – http://0xlab.org/
善用強大的系統模擬器 QEMU

           不只是「窮人的 ARM 開發板」 ( 中國北京清華大學
           Skyeye 開發團隊的故事 )
           對於學習 / 分析 ARM 架構與指令集,提供一個高
           整合度的互動環境
                內建 instruction­level tracer
                gdb server 的整合
             豐富的週邊硬體模擬
           Android SDK/Emulator 的
           goldfish 虛擬硬體平台
後續的實驗部份皆以 QEMU 模擬硬體環境                                            59
0xlab – connect your device to application – http://0xlab.org/
豐富的硬體模擬環境
       Openmoko GTA01/GTA02 emulated by QEMU
       ARMv4t / Samsung S3C2410/2442
       Sharp PDAs emulated by QEMU 
       ARMv5te / Marvell PXA2xx
       ARM Versatile PB board emulated by QEMU
       ARM926ej
       Gumstix
       ARMv5te / Marvell PXA25x
       (hardware model: connex)



                                                                 60
0xlab – connect your device to application – http://0xlab.org/
Emulated by QEMU




                  Serial / JTAG / TCP-IP




                                                                 61
0xlab – connect your device to application – http://0xlab.org/
QEMU 回顧 (1)
    快速的模擬器: Portable dynamic translator




    完整系統模擬
          instruction set + processor + peripherals
          硬體平台: x86, x86_64, ppc, arm, sparc, mips, nds( 台灣心 )
          指定特定機器: qemu­system­arm ­M ?
    兩種模擬模式: User, System 關於 QEMU 的原理,可參考拙作〈 QEMU JIT
                                                  62
                                                             Code Generator & System Emulation 〉
0xlab – connect your device to application – http://0xlab.org/
QEMU 回顧 (2)

     兩種執行模式
         user mode emulation :可執行非原生架構之應用程式
         支援: x86, ppc, arm, sparc, mips
         system emulation
              qemu linux.img
              也可分別指定 kernel image 、 initrd ,及相關參數
         以 xscale 為例:
~/poky/build/tmp$ file ./rootfs/bin/busybox        使用 ARM target 的 ld-linux.so.2
./rootfs/bin/busybox: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux
2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, stripped
~/poky/build/tmp$ ./qemu-arm ./rootfs/lib/ld-linux.so.2 
--library-path ./rootfs/lib ./rootfs/bin/busybox uname -a
Linux venux 2.6.20-12-generic #2 SMP Sun Mar 18 03:07:14 UTC 2007 armv5tel
unknown
                                                                  Processor 變成 armv5te (Xscale)
                                                                                              63
 0xlab – connect your device to application – http://0xlab.org/
QEMU 回顧 (3)

  gdb stub
     考慮在 system emulation 模式下,該如何喚起 gdb ?
     Remote Debugging : gdb 可透過 serial line 或 TCP/IP
     進行遠端除錯




                                                        gdb stub
 開發平台 (Host)
 運作完整的 GDB                                                     Qemu 所模擬的機器   64
0xlab – connect your device to application – http://0xlab.org/
QEMU 回顧 (4)

    gdb stub :透過 TCP/IP
        (gdb) target remote localhost:1234
        qemu 執行選項:
             ­s  Wait gdb connection to port 1234.
             ­S  Do not start CPU at startup




                                   localhost:1234

                                                                     gdb stub
開發平台 (Host)
運作完整的 GDB                                                        Qemu 所模擬的機器    65
0xlab – connect your device to application – http://0xlab.org/
[PLAN] 將自製的 CuRT 作業系統運作於 PXA255 (emulated by QEMU) ,
  透過 gdb stub 及 TCP/IP ,與 host 端進行 Remote debugging
   # dd of=flash­image bs=1k count=16k if=/dev/zero
   # dd of=flash­image bs=1k conv=notrunc if=curt_image.bin
   # qemu­system­arm ­M connex ­pflash flash­image ­serial stdio ­s ­S

                     wait gdb connection to port 1234.

     CuRT 後續維護 (by cyt93cs)                                      CuRT 原始程式碼: (BSD 授權 )
http://code.google.com/p/curt­v1­rework/                         http://jserv.sayya.org/kernel/


   Emulated by QEMU


                  Serial / JTAG / TCP-IP




                                                                                             66
0xlab – connect your device to application – http://0xlab.org/
CuRT 準備動作 (1)


                                                                      # cd app/shell
 取得 CodeSourcery GNU Toolchain 2009q1                                 # make
     解開安裝於 /usr/local/csl 目錄下
於兩個 X 終端機視窗設定必要的 $PATH 環境變數




… ( 參考的編譯畫面 ) ...
arm­none­linux­gnueabi­ld ­nostdlib ­static ­e _start ­p ­­no­undefined ­X ­T ld­
script.lds 
         ­o curt_image.elf 
         ./main.o ../../device/serial.o ../../lib/stdio.o ../../arch/arm/mach­
pxa/port.o ../../arch/arm/mach­pxa/start.o ../../arch/arm/mach­pxa/asm_port.o 
../../kernel/kernel.o ../../kernel/thread.o ../../kernel/list.o 
../../kernel/sync.o ../../kernel/ipc.o
arm­none­linux­gnueabi­objcopy ­O binary ­R .note ­R .note.gnu.build­id ­R .comment ­S 
curt_image.elf curt_image.bin
#                                       檔案 curt_image.elf 為包含除錯資訊的 ELF 執行檔                67
0xlab – connect your device to application – http://0xlab.org/
CuRT 準備動作 (2)


                                                                 # ./prepare_flash
                                                                 # ./run­on­connex­debug




                     # cgdb ­d arm­none­linux­gnueabi­gdb curt_image.elf
                         cgdb 是 CURSES 介面撰寫的 GNU GDB 前端,有著類似 vim 的操作環境
                         預先載入 CuRT 的除錯資訊檔案




                                                                                       68
0xlab – connect your device to application – http://0xlab.org/
CuRT 準備動作 (3)


                                                                 因為 qemu 啟動時加上 ­s ­S 參數,會
                                                                 等待 remote gdb 連線才會繼續執行
                                  QEMU
( 在 QEMU 視窗出現後,按下 Ctrl­Alt­2 組合鍵,可切換到 QEMU monitor 畫面 )




                                                                 (gdb) target remote :1234



 一旦 qemu 視窗出現,即可準備
 remote gdb 連線,在 cgdb 下方
 視窗敲入指令

 連線到 qemu 後,按下 'c'  要求
 繼續執行

                                                                                         69
0xlab – connect your device to application – http://0xlab.org/
QEMU monitor
                  ( 在 QEMU 視窗出現後,按下 Ctrl­Alt­2 組合鍵,可切換到 QEMU monitor 畫面 )




                                                                 (qemu) info registers




  在 gdb 中按下 Ctrl-C
  組合鍵以搶得控制權
          static void shell_thread_func(void *pdata){
              …
            While (1) {
                  ...
                  gets(buf);                                                             Debugger
                                                                                               70
0xlab – connect your device to application – http://0xlab.org/
QEMU monitor




                               (qemu) info registers
                               R00=00000000 R01=00000020 R02=00000020 R03=00000000
                               R04=04040404 R05=05050505 R06=06060606 R07=07070707
                               R08=08080808 R09=09090909 R10=10101010 R11=a000c438
                               R12=12121212 R13=a000c42c R14=a0001828 R15=a0000bbc
                               PSR=60000013 ­ZC­ A svc32

                                       r0                 r8
                                       r1                 r9       31            0
                                       r2                r10
                                       r3                r11              CPSR
                                       r4                r12
                ARM                    r5                r13
                                                                    – Z C – 
                Registers              r6                r14
                                                                                     71
                                       r7           r15 (PC)
0xlab – connect your device to application – http://0xlab.org/
QEMU monitor




                          Processor Mode
                          svc : supervisor



                  r0        r8
                  r1        r9
                  r2 r10
                  r3 r11
                  r4 r12
      ARM         r5 r13
      Regs        r6 r15 (PC)
                          r14                                    72
                  r7
0xlab – connect your device to application – http://0xlab.org/
Basic Processor Modes

          User (usr) – Normal program execution modes
          FIQ (fiq) – Support a high­speed data transfer or channel 
          process
          IRQ (irq) – Used for general­purpose interrupt handling
          Supervisor (svc) – A protected mode for OS
                        entered on reset and when a Software Interrupt   
                       instruction executed.
          Abort (abt) – Implements VM and/or memory protection
          Undefined (und) – Support software emulation of HW 
          coprocessors
          System: sys – Run privileged OS tasks
        fiq, irq, svc, abt, und – exception modes

                                                                            73
0xlab – connect your device to application – http://0xlab.org/
Interrupt 是 Exception 的特例                                        74
0xlab – connect your device to application – http://0xlab.org/
r0                           r8
                              r1                           r9        31              0
                              r2                          r10
                              r3                          r11                 CPSR
                              r4                          r12
                              r5                          r13
                                                                      N Z C V
                              r6                          r14
                              r7                       r15 (PC)
                                                                     Link register
                  unbanked registers              banked registers


    Every arithmetic, logical, or shifting operation may set CPSR 
    (current program statues register) bits:
          N (negative), Z (zero), C (carry), V (overflow).
    Examples: 
          ­1 + 1 = 0:           NZCV = 0110.
          231­1+1 = ­231:  NZCV = 0101.
                                                                                         75
0xlab – connect your device to application – http://0xlab.org/
ARM Register Set


        Current Visible Registers
        Current Visible Registers
                        r0
                         r0
  Undef Mode
   Abort
  SVC Mode
  IRQ Mode
  UserMode
   FIQ Mode
                        r1
                         r1
                        r2
                         r2
                        r3
                         r3                                            Banked out Registers
                                                                       Banked out Registers
                        r4
                         r4
                        r5
                         r5
                        r6
                         r6                    User
                                               User          FIQ          IRQ
                                                                           IRQ       SVC
                                                                                      SVC        Undef
                                                                                                 Undef      Abort
                                                                                                            Abort
                        r7
                         r7
                        r8
                         r8                       r8             r8
                        r9
                         r9                       r9             r9
                        r10
                         r10                     r10             r10
                        r11
                         r11                     r11             r11
                        r12
                         r12                     r12             r12
                     r13 (sp)
                      r13 (sp)                r13 (sp)
                                               r13 (sp)    r13 (sp)     r13 (sp)
                                                                         r13 (sp)   r13 (sp)
                                                                                     r13 (sp)   r13 (sp)
                                                                                                 r13 (sp)   r13 (sp)
                                                                                                             r13 (sp)
                     r14 (lr)
                      r14 (lr)                r14 (lr)
                                               r14 (lr)    r14 (lr)     r14 (lr)
                                                                         r14 (lr)   r14 (lr)
                                                                                     r14 (lr)   r14 (lr)
                                                                                                 r14 (lr)   r14 (lr)
                                                                                                             r14 (lr)
                     r15 (pc)
                      r15 (pc)

                       cpsr
                        cpsr
                       spsr
                        spsr                                 spsr         spsr
                                                                           spsr       spsr
                                                                                       spsr       spsr
                                                                                                   spsr       spsr
                                                                                                               spsr

                                                                                                                      76
0xlab – connect your device to application – http://0xlab.org/
ARM Register Set – All modes

        User             FIQ            IRQ             SVC       Undef      Abort

          r0
          r1
                         User
          r2
                         mode
          r3            r0-r7,
          r4             r15,
                                         User            User       User       User     Thumb state
                          and
          r5                             mode            mode       mode       mode
                         cpsr
                                       r0-r12,         r0-r12,    r0-r12,    r0-r12,
                                                                                        Low registers
          r6
                                         r15,            r15,       r15,       r15,
          r7                             and             and        and        and
          r8              r8             cpsr            cpsr       cpsr       cpsr
          r9              r9
         r10              r10                                                           Thumb state
         r11              r11
                                                                                        High registers
         r12              r12
      r13 (sp)         r13 (sp)       r13 (sp)         r13 (sp)   r13 (sp)   r13 (sp)
      r14 (lr)         r14 (lr)       r14 (lr)         r14 (lr)   r14 (lr)   r14 (lr)
      r15 (pc)

        cpsr
                         spsr            spsr            spsr       spsr       spsr


     Note: System mode uses the User mode register set
                                                                                                     77
0xlab – connect your device to application – http://0xlab.org/
ARM Registers

           ARM 有 37 個暫存器,皆為 32­bit 長度
                1 個專屬的 PC (program counter)

                1 個專屬的 CPSR (current program status register)

                5 個專屬的 SPSR ( saved program status registers)

                30 個通用的暫存器

           規劃
                通用組 : r0­r12 registers
                挪作特別使用 : r13 (stack pointer, sp), r14 (link register, lr)
                 program counter, r15 (pc)

                                                                 故實際僅有 16 個可見的暫存器   78
0xlab – connect your device to application – http://0xlab.org/
IRQ and FIQ 

    • Program Status Register 
     31 30 29 28 27 … 8                                7         6   5   4   3   2   1   0
        N      Z      C       V                              I       F       M4 M3 M2 M1 M0
         – 若要抑制 interrupts ,將 "F” 或 “ I” bit 設定為 1 
    • 一旦 interrupt 觸發,處理器將變更至 FIQ32_mode registers 
      或 IRQ32_mode registers 
              •   Switch register banks 
              •   Copies CPSR to SPSR_mode (saves mode, interrupt flags, etc.)
              •   Changes the CPSR mode bits (M[4:0])
              •   Disables interrupts 
              •   Copies PC to R14_mode (to provide return address)
              •   Sets the PC to the vector address of the exception handler 


                                                                                              79
0xlab – connect your device to application – http://0xlab.org/
Interrupt Handlers 

       • 當 interrupt 發生時,硬體會跳躍到 interrupt handler
                                                                                                     time
                      user program                                      user program
      Task
                                            IRQ Interrupt handler
      IRQ
      FIQ


                                                                 • On interrupt, the processor will set the 
                                                                   corresponding interrupt bit in the CPSR to 
                                  Interrupt                        disable subsequent interrupts of the 
                                                                   same type from occurring. 
                                                                 • However, interrupts of a higher priority 
                                                                   can still occur.

                                                                                                            80
0xlab – connect your device to application – http://0xlab.org/
Nested/Re­entrant Interrupts 
       • 但是, interrupts 也可能在執行 interrupt handlers 時
         被觸發,此為 nested( 巢狀 ) interrupt              time
                      user program                                                user program
      Task
                                            IRQ Interrupt handler
      IRQ
                                                        FIQ Interrupt handler
      FIQ



                                                                 • On interrupt, the processor will set the 
                                  Interrupt                        corresponding interrupt bit in the CPSR to 
                                                                   disable subsequent interrupts of the 
                                                                   same type from occurring. 
                                         Second                  • However, interrupts of a higher priority 
                                        Interrupt                  can still occur.

                                                                                                           81
0xlab – connect your device to application – http://0xlab.org/
Timing of Interrupts 
       • 在 interrupt handler 實際運作前,必須保存目前程
         式 (context) 的 register ( 若觸及這些 register) 
       • 這也是何以 FIQ 需要額外 register 的緣故,為了
         降低 CPU 保存 context 的成本開銷
                                                                                                  time
                        user program                                       user program
                                                    cpu context saved
       Task
       IRQ
                                                 “servicing” interrupt
       FIQ                                                                 cpu context restored


                Interrupt latency


                          Interrupt
                                                      Interrupt response
                                                                                                         82
0xlab – connect your device to application – http://0xlab.org/
Michael Jordan said...

                                                      I can accept failure.
                                              Everyone fails at something.
                                             But I cannot accept not trying.




                                                                 在 Part II 議程中,將會以
                                                                 CuRT 為例,探討前述觀念
                                                                 的實務

                                                                 繼續探索 PXA255 SoC     83
0xlab – connect your device to application – http://0xlab.org/
84
0xlab – connect your device to application – http://0xlab.org/
PXA255 Function Block


                                    RTC
                                                                                                            Memory
                                  OS Timer                                                                 Controller
                                  PWM(2)                                         0x4400_0000
                                                                                                            PCMCIA
                                                                                                             & CF        XCVR
                                 Interrupt                                                                  Control
                                 Controller
                                                                                                                            Socket 0, 1
                                   Clock &                                        System Bus
                                 Power Man.
                                                                                                            Dynamic      SDRAM/
                                    I2S                                                                     Memory       SMROM
                                                                                                            Control      4 banks
                                    I2C
                                                                     Megacell
                                    AC97                                           Write         Read
                                                                      Core         Buffer        Buffer
                                  FF_UART
                                  BT_UART                                                                   Variable
                                                                                     Load/Store Data        Latency
                                              s u Bl ar e hp r e P




                                 Slow lrDA                                                                    I/O         ASIC
                                                                                  Dcache Addr
      O/ I es op uPl ar e ne G




                                                                     DMMU                                   Control
                                                           i




                                  Fast lrDA                                     (32 Kbytes)
                                    SSP                                         Minicache         XScale                   CS
                                                                                                   Core                   #3,4,5
                                   NSSP                                           Icache    PC
                                                                     IMMU                                                 ROM/
                                                                                (32 Kbytes)                  Static
                                    USB                                                                     Memory        Flash
                                                                                       Instructions
                r




                                   Client                                                                   Control       SRAM
                                                                                                                         4 banks
                                    MMC                               3.6864 MHz             32.768 KHz
                                                                          Osc                    Osc                    CS #0,1,2
                                                                                                                        Color or Grayscale
                                                                                                                          LCD Controller
                                                                                                                                          85
0xlab – connect your device to application – http://0xlab.org/
PXA255 Memory Model




                                                                 MMU   On-chip     Core
                                                                       Caches

                                                             Buffers

         Memory
                                 Memory
                                Controller
                                                  Physical Addresses    Virtual Addresses




    http://www.intel.com/design/pca/prodbref/252780docs.htm                                 86
0xlab – connect your device to application – http://0xlab.org/
Memory Map
   0hFFFF FFFF
                               Reserved (1280 Mbytes)

  0hB000 0000
                             SDRAM Bank 3 (64 Mbytes)
   0hAC00 0000
                             SDRAM Bank 2 (64 Mbytes)            Dynamic Memory Interface
  0hA800 0000                                                    256 Mbytes
                             SDRAM Bank 1 (64 Mbytes)
  0hA400 0000
                             SDRAM Bank 0 (64 Mbytes)
  0hA000 0000
                               Reserved (1344 Mbytes)

  0h4C00 0000
                      Memory Mapped registers (Memory Control)
   0h4800 0000                                                   Memory Mapped registers Interface
                           Memory Mapped registers (LCD)
   0h4400 0000                                                   192 Mbytes
                        Memory Mapped registers (Peripherals)
  0h4000 0000
                                 PCMCIA/CF - Slot 1
                                   (256 Mbytes)
   0h3000 0000                                                   PCMCIA Interface 512 Mbytes
                                 PCMCIA/CF - Slot 0
                                   (256 Mbytes)
   0h2000 0000
                       Reserved (128 Mbytes)
   0h1800 0000
                           Static Chip Select 5 (64 Mbytes)
   0h1400 0000
                           Static Chip Select 4 (64 Mbytes)
   0h1000 0000
                           Static Chip Select 3 (64 Mbytes)      Static Memory Interface (ROM, Flash,
   0h0C00 0000
                           Static Chip Select 2 (64 Mbytes)      SRAM) 384 Mbytes
   0h0800 0000

   0h0400 0000
                           Static Chip Select 1 (64 Mbytes)
                                                                  0x4000000-0x4C00000 之間的
                                                                     Memory Mapped 區域
                           Static Chip Select 0 (64 Mbytes)
   0h0000 0000
                                                                                                        87
0xlab – connect your device to application – http://0xlab.org/
Memory Map
                                                        在 SoC 上,週邊 (peripheral) 被對應到
 0hFFFF FFFF
                         Reserved (1280 Mbytes)         特定的記憶體區段,直接操作該記憶體,
 0hB000 0000
                       SDRAM Bank 3 (64 Mbytes)
                                                        即可控制週邊硬體裝置
 0hAC00 0000
                       SDRAM Bank 2 (64 Mbytes)             MMIO (Memory-Mapped Input/Output)
                                                             Dynamic Memory Interface
 0hA800 0000                                                 256 Mbytes
                       SDRAM Bank 1 (64 Mbytes)
 0hA400 0000
                       SDRAM Bank 0 (64 Mbytes)
 0hA000 0000
                         Reserved (1344 Mbytes)

 0h4C00 0000
                Memory Mapped registers (Memory Control)
 0h4800 0000                                                 Memory Mapped registers
                     Memory Mapped registers (LCD)
 0h4400 0000                                                 Interface
                  Memory Mapped registers (Peripherals)
 0h4000 0000                                                 192 Mbytes
                           PCMCIA/CF - Slot 1
                             (256 Mbytes)
 0h3000 0000                                                 PCMCIA Interface 512 Mbytes
                           PCMCIA/CF - Slot 0
                             (256 Mbytes)
 0h2000 0000
                 Reserved (128 Mbytes)
 0h1800 0000
                     Static Chip Select 5 (64 Mbytes)
   0h1400
    0000             Static Chip Select 4 (64 Mbytes)
 0h1000 0000
                     Static Chip Select 3 (64 Mbytes)        Static Memory Interface (ROM,
 0h0C00 0000
 0h0800 0000
                     Static Chip Select 2 (64 Mbytes)        Flash,
                     Static Chip Select 1 (64 Mbytes)         SRAM) 384 Mbytes
 0h0400 0000
                     Static Chip Select 0 (64 Mbytes)
 0h0000 0000

                                                        對 PXA255 來說,即 0x0x4000000-0x4400000     88
0xlab – connect your device to application – http://0xlab.org/
PXA255 core Function Diagram
                                                UDC-                    L_DD(15:0)

     Serial Channel 0 (USB)                    UDC+                     L_FCLK

                                               RXD_1                    L_LCLK
        Serial Channel 1                                                L_PCLK
                                                                                           LCD Control
                                               TXD_1
                                               RXD_2                    L_BIAS

   Serial Channel 2 (IrDA)                     TXD_2                    GP(27:0)
                                                                        nCAS/ DQM(3:0)     GPIO Ports
                                               RXD_3

   Serial Channel 3 (UART)                     TXD_3                    nRAS/ nSDCS(3:0)
                                               TXD_C                    nOE

                                               RXD_C                    nWE

 Serial Channel 4(CODEC)                      SFRM_C                    nCS(5:0)
                                                                        RDY
                                                                                           Memory Control
                                              SCLK_C
                                         BATT_FAULT                     nSDRAS
                                                            Intelⓡ
                                           VDD_FAULT                    nSDCAS
    Power Management                                        XScale*
                                             PWR_EN        PXA 250      SDCKE<1:0>
                                                          [256-pins]    SDCLK<2:0>
                                             TCK_BYP
                                                                        RD/nWR
                                             TESTCLK                                       Transceiver Control
                                                                        nPOE
                                               PEXTAL
                                                                        nPWE
                                               PXTAL                    nPIOR
                                                                        nPIOW
                                              TEXTAL                    nPCE<2:1>
                                               TXTAL                    PSKTSEL            PCMCIA Bus Signals
      Clocks, Reset and Test                                            nPREG
                                              nRESET
                                                                        nPWAIT
                                      nRESET_OUT                        nIOIS16
                                         SMROM_EN
                                                                              A<25:0>      Address Bus
                                             ROM_SEL
                                                 TCK
                                                  TDI
                                                                                 D<31:0>   Data Bus
                                                 TDO                   VDD
                    JTAG                         TMS                   VDDX
                                               nTRST                   VSS/VSSX            Supply



                                                                                                                 89
0xlab – connect your device to application – http://0xlab.org/
PXA255 Serial/UART
                                                            UDC-                    L_DD(15:0)

                            Serial Channel 0               UDC+                     L_FCLK

                                       (USB)               RXD_1                    L_LCLK
                              Serial Channel               TXD_1                    L_PCLK
                                                                                                       LCD Control
                                       1                   RXD_2                    L_BIAS
                            Serial Channel 2               TXD_2                    GP(27:0)
                                   (IrDA)                  RXD_3                    nCAS/ DQM(3:0)     GPIO
                                                                                    nRAS/ nSDCS(3:0)   Ports
                            Serial Channel 3               TXD_3
                                  (UART)                   TXD_C                    nOE
                                                           RXD_C                    nWE

                              Serial Channel              SFRM_C                    nCS(5:0)
                                                                                    RDY
                                                                                                       Memory
                              4(CODEC)                    SCLK_C
                                                                                                       Control
                                                     BATT_FAULT                     nSDRAS
                                                                        Intelⓡ
                                                       VDD_FAULT                    nSDCAS
                         Power Management                               XScale*
                                                         PWR_EN                     SDCKE<1:0>
                                                                       PXA 250
Universal Asynchronous Receiver/Transmitter (UART): controller
                                                         TCK_BYP      [256-pins]
                                                                                    SDCLK<2:0>
                                                                                    RD/nWR
                                                         TESTCLK                                       Transceiver
                                                                                    nPOE
                                                          PEXTAL
                                                                                    nPWE
                                                                                                       Control
                                                           PXTAL                    nPIOR
                                                                                    nPIOW
                                                          TEXTAL                    nPCE<2:1>
                                                           TXTAL                    PSKTSEL            PCMCIA Bus
                           Clocks, Reset and                                        nPREG              Signals
                                        Test              nRESET
                                                    nRESET_OUT                     Terminal
                                                                                    nPWAIT
                                                                                    nIOIS16
                                    Parallel­to­Serial TX
                                    Parallel­to­SerialROM_SEL
                                                      SMROM_EN            RX              A<25:0>      Address Bus
                                       Converter
                                       Converter          TCK
                                                                                          D<31:0>      Data
Computer CPU
                                                              TDI

         CPU                        JTAG
                                                             TDO
                                                             TMS
                                                                                   VDD
                                                                                   VDDX
                                                                                                       Bus

                                    Serial­to­Parallel RX                 TX                           Supply
                                    Serial­to­Parallel     nTRST                   VSS/VSSX


                                        Converter
                                       Converter
                                                                    Serial
                                                                     Link                                            90
0xlab – connect your device to application – http://0xlab.org/
UDC-                   L_DD(15:0)

  Serial Channel 0                UDC+                    L_FCLK

             (USB)                RXD_1                   L_LCLK
    Serial Channel                TXD_1                   L_PCLK
                                                                             LCD Control
             1                    RXD_2                   L_BIAS
  Serial Channel 2                TXD_2                   GP(27:0)
         (IrDA)                   RXD_3                   nCAS/ DQM(3:0)     GPIO
                                                          nRAS/ nSDCS(3:0)   Ports
  Serial Channel 3                TXD_3
        (UART)                    TXD_C                   nOE
                                  RXD_C                   nWE

     Serial Channel              SFRM_C                   nCS(5:0)
                                                          RDY
                                                                             Memory
     4(CODEC)                    SCLK_C
                                                                             Control
                            BATT_FAULT                    nSDRAS
                                             Intelⓡ
                            VDD_FAULT                     nSDCAS
Power Management                           XScale*
                                                          SDCKE<1:0>
 Universal Asynchronous Receiver/Transmitter
                              PWR_EN
                                           PXA 250
                                                          SDCLK<2:0>
  (UART): controller          TCK_BYP    [256-pins]
                                                          RD/nWR
                                TESTCLK                                      Transceiver
                                                          nPOE
                                 PEXTAL
                                                          nPWE
                                                                             Control
                                  PXTAL                   nPIOR
                                                          nPIOW
                                 TEXTAL                   nPCE<2:1>
                                  TXTAL                   PSKTSEL            PCMCIA Bus
 Clocks, Reset and                                        nPREG              Signals
                                 nRESET
              Test                                        nPWAIT
                          nRESET_OUT                      nIOIS16
                            SMROM_EN                                         Address Bus
                                                                A<25:0>
                                ROM_SEL
                                    TCK
                                     TDI
                                                                D<31:0>      Data
                                    TDO                  VDD
           JTAG                     TMS                  VDDX
                                                                             Bus
                                  nTRST                  VSS/VSSX            Supply




 FFUART (Full function UART) 的
       (memory mapped)
  base address 為 0x40100000                                                                91
  0xlab – connect your device to application – http://0xlab.org/
Data Communication 
  • 透過 serial line 建立電腦與終端機模擬程式的通訊
       – Data is converted from parallel (bytes) to serial (bits) in the bus 
         interface 
       – Bits are sent over wire (TX) to terminal (or back from terminal to 
         computer) 
       – Receiving end (RX) translates bit stream back into parallel data 
         (bytes) 


                                                                               Terminal
                                             Parallel­to­Serial TX
                                            Parallel­to­Serial
                                                                          RX
                                                Converter
                                               Converter
  Computer CPU
           CPU
                                             Serial­to­Parallel RX
                                            Serial­to­Parallel
                                                                          TX
                                                Converter
                                               Converter
                                                                     Serial
                                                                      Link                92
0xlab – connect your device to application – http://0xlab.org/
Serial Port 

      RxRegister        0 1 2 3 4 5 6 7                          RxRegister    0 1 2 3 4 5 6 7
      FIFO Buffer                                                FIFO Buffer


                        0 1 2 3 4 5 6 7                                        0 1 2 3 4 5 6 7
                                 Clock                                              Clock
                        0 1 2 3 4 5 6 7                                        0 1 2 3 4 5 6 7

     FIFO Buffer                                                 FIFO Buffer
     TxRegister                                                  TxRegister
                        0 1 2 3 4 5 6 7                                        0 1 2 3 4 5 6 7


                      Processor                                                Peripheral
                                                                                                 93
0xlab – connect your device to application – http://0xlab.org/
Sample shell for CuRT


                                                                                  CuRT_v1/app/shell/main.c
                                                                                  CuRT_v1/app/shell/main.c
                                                                  int main()
                                                                  int main()
                                                                  {
                                                                  {
                                                                      SerialInit();
                                                                      SerialInit();
                                                                      init_interrupt_control();
                                                                      init_interrupt_control();
                                                                      init_curt();
                                                                      init_curt();

                                                                      ...
                                                                      ...
                                                                      shell_tid = thread_create(&shell_thread,
                                                                      shell_tid = thread_create(&shell_thread,
                                                                          &thread_stk[0][THREAD_STACK_SIZE-1],
                                                                          &thread_stk[0][THREAD_STACK_SIZE-1],
                                                                          shell_thread_func,
                                                                          shell_thread_func,
                                                                          "shell_thread",
                                                                          "shell_thread",
                                                                          5, NULL);
                                                                          5, NULL);




                                                                               CuRT_v1/app/shell/main.c
                                                                               CuRT_v1/app/shell/main.c
                                                                 static void shell_thread_func(void *pdata)
                                                                 static void shell_thread_func(void *pdata)
                                                                 {
                                                                 {
                                                                     ...
                                                                     ...
                                                                     char buf[80] = { '0' };
                                                                     char buf[80] = { '0' };
                                                                     while (1) {
                                                                     while (1) {
                                                                         printf("$ ");
                                                                         printf("$ ");
                                                                         gets(buf);
                                                                         gets(buf);
                                                                         printf("n");
                                                                         printf("n");
                                                                         ...
                                                                         ...
                                                                         else if (!strcmp(buf, "stat")) {
                                                                         else if (!strcmp(buf, "stat")) {
                                                                             thread_resume(stat_tid);
                                                                             thread_resume(stat_tid);         94
0xlab – connect your device to application – http://0xlab.org/
Serial “Driver” in CuRT
                                                                 CuRT_v1/device/serial.c
                                                                 CuRT_v1/device/serial.c
                                    void SerialInit(void)
                                    void SerialInit(void)
                                    {
                                    {
                                            /* GP39, GP40, GP41 UART(10) */
                                            /* GP39, GP40, GP41 UART(10) */
                                            GAFR1_L |= 0x000A8000;
                                            GAFR1_L |= 0x000A8000;
                                            GPDR1 |= 0x00000380;
                                            GPDR1 |= 0x00000380;

                                            /* 8-bit, 1 stop, no parity */
                                            /* 8-bit, 1 stop, no parity */
                                            rFFLCR = 0x00000003;
                                            rFFLCR = 0x00000003;

                                            /* Reset tx, rx FIFO. clear. FIFO enable */
                                            /* Reset tx, rx FIFO. clear. FIFO enable */
                                            rFFFCR = 0x00000007;
                                            rFFFCR = 0x00000007;

                                            /* UART Enable Interrupt */
                                            /* UART Enable Interrupt */
                                            rFFIER = 0x00000040;
                                            rFFIER = 0x00000040;


                                            對 PXA255 之 FF_UART
                                            (Full Function UART) 作初始化
                                 XScale
    FF_UART                       Core
                  r e hp r e P




                                                                                          95
                       i




0xlab – connect your device to application – http://0xlab.org/
ARM and SoC Traning Part I -- Overview
ARM and SoC Traning Part I -- Overview
ARM and SoC Traning Part I -- Overview
ARM and SoC Traning Part I -- Overview
ARM and SoC Traning Part I -- Overview
ARM and SoC Traning Part I -- Overview
ARM and SoC Traning Part I -- Overview

More Related Content

What's hot

SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMUSFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMULinaro
 
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)William Liang
 
Find your own iOS kernel bug
Find your own iOS kernel bugFind your own iOS kernel bug
Find your own iOS kernel bugGustavo Martinez
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded LinuxTushar B Kute
 
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)Mr. Vengineer
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New HardwareRuggedBoardGroup
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time OptimizationKan-Ru Chen
 
The Microkernel Mach Under NeXTSTEP
The Microkernel Mach Under NeXTSTEPThe Microkernel Mach Under NeXTSTEP
The Microkernel Mach Under NeXTSTEPGregor Schmidt
 
makefiles tutorial
makefiles tutorialmakefiles tutorial
makefiles tutorialvsubhashini
 
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例National Cheng Kung University
 
Tegra 186のu-boot & Linux
Tegra 186のu-boot & LinuxTegra 186のu-boot & Linux
Tegra 186のu-boot & LinuxMr. Vengineer
 
ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門Fixstars Corporation
 

What's hot (20)

Embedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile DevicesEmbedded Virtualization applied in Mobile Devices
Embedded Virtualization applied in Mobile Devices
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMUSFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
SFO15-202: Towards Multi-Threaded Tiny Code Generator (TCG) in QEMU
 
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
 
Linux Programming
Linux ProgrammingLinux Programming
Linux Programming
 
Find your own iOS kernel bug
Find your own iOS kernel bugFind your own iOS kernel bug
Find your own iOS kernel bug
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded Linux
 
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
The Microkernel Mach Under NeXTSTEP
The Microkernel Mach Under NeXTSTEPThe Microkernel Mach Under NeXTSTEP
The Microkernel Mach Under NeXTSTEP
 
makefiles tutorial
makefiles tutorialmakefiles tutorial
makefiles tutorial
 
Linux Device Tree
Linux Device TreeLinux Device Tree
Linux Device Tree
 
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
 
LLVM introduction
LLVM introductionLLVM introduction
LLVM introduction
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
 
Tegra 186のu-boot & Linux
Tegra 186のu-boot & LinuxTegra 186のu-boot & Linux
Tegra 186のu-boot & Linux
 
ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門
 

Similar to ARM and SoC Traning Part I -- Overview

Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systemsjoshparrish13
 
SNAPDRAGON SoC Family and ARM Architecture
SNAPDRAGON SoC Family and ARM Architecture SNAPDRAGON SoC Family and ARM Architecture
SNAPDRAGON SoC Family and ARM Architecture Abdullaziz Tagawy
 
Kernel Recipes 2013 - ARM support in the Linux kernel
Kernel Recipes 2013 - ARM support in the Linux kernelKernel Recipes 2013 - ARM support in the Linux kernel
Kernel Recipes 2013 - ARM support in the Linux kernelAnne Nicolas
 
Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systemsajaydudani
 
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...Anne Nicolas
 
0xdroid -- community-developed Android distribution by 0xlab
0xdroid -- community-developed Android distribution by 0xlab0xdroid -- community-developed Android distribution by 0xlab
0xdroid -- community-developed Android distribution by 0xlabNational Cheng Kung University
 
Enterprise power systems transition to power7 technology
Enterprise power systems transition to power7 technologyEnterprise power systems transition to power7 technology
Enterprise power systems transition to power7 technologysolarisyougood
 
COMPLETE DETAIL ABOUT ARM PART1
COMPLETE DETAIL ABOUT ARM PART1COMPLETE DETAIL ABOUT ARM PART1
COMPLETE DETAIL ABOUT ARM PART1NOWAY
 
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded Devices
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded DevicesQi -- Lightweight Boot Loader Applied in Mobile and Embedded Devices
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded DevicesNational Cheng Kung University
 
Arm processor architecture awareness session pi technologies
Arm processor architecture awareness session pi technologiesArm processor architecture awareness session pi technologies
Arm processor architecture awareness session pi technologiesPiTechnologies
 
Symbian OS With ARM Processor
Symbian OS With ARM ProcessorSymbian OS With ARM Processor
Symbian OS With ARM Processoralok3089
 
Sun Microsystems:Case Studyv1
Sun Microsystems:Case Studyv1Sun Microsystems:Case Studyv1
Sun Microsystems:Case Studyv1Das Sunny
 
Porting linux on ARM
Porting linux on ARMPorting linux on ARM
Porting linux on ARMSatpal Parmar
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSDr.YNM
 
CPU Architectures for Mobile Phone Devices
CPU Architectures for Mobile Phone DevicesCPU Architectures for Mobile Phone Devices
CPU Architectures for Mobile Phone Devicessagar chansaulia
 
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...Intel® Software
 
BlackHat_DC_2011_Avraham_ARM Exploitation-wp.2.0
BlackHat_DC_2011_Avraham_ARM Exploitation-wp.2.0BlackHat_DC_2011_Avraham_ARM Exploitation-wp.2.0
BlackHat_DC_2011_Avraham_ARM Exploitation-wp.2.0Zuk Avraham
 

Similar to ARM and SoC Traning Part I -- Overview (20)

Arm 1-overview-090720075211-phpapp01
Arm 1-overview-090720075211-phpapp01Arm 1-overview-090720075211-phpapp01
Arm 1-overview-090720075211-phpapp01
 
Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systems
 
ARM Processor Tutorial
ARM Processor Tutorial ARM Processor Tutorial
ARM Processor Tutorial
 
SNAPDRAGON SoC Family and ARM Architecture
SNAPDRAGON SoC Family and ARM Architecture SNAPDRAGON SoC Family and ARM Architecture
SNAPDRAGON SoC Family and ARM Architecture
 
Kernel Recipes 2013 - ARM support in the Linux kernel
Kernel Recipes 2013 - ARM support in the Linux kernelKernel Recipes 2013 - ARM support in the Linux kernel
Kernel Recipes 2013 - ARM support in the Linux kernel
 
Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systems
 
Axiom Magazine: Volume 1, Issue 3, October 2013
Axiom Magazine: Volume 1, Issue 3, October 2013Axiom Magazine: Volume 1, Issue 3, October 2013
Axiom Magazine: Volume 1, Issue 3, October 2013
 
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
Embedded Recipes 2019 - Knowing your ARM from your ARSE: wading through the t...
 
0xdroid -- community-developed Android distribution by 0xlab
0xdroid -- community-developed Android distribution by 0xlab0xdroid -- community-developed Android distribution by 0xlab
0xdroid -- community-developed Android distribution by 0xlab
 
Enterprise power systems transition to power7 technology
Enterprise power systems transition to power7 technologyEnterprise power systems transition to power7 technology
Enterprise power systems transition to power7 technology
 
COMPLETE DETAIL ABOUT ARM PART1
COMPLETE DETAIL ABOUT ARM PART1COMPLETE DETAIL ABOUT ARM PART1
COMPLETE DETAIL ABOUT ARM PART1
 
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded Devices
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded DevicesQi -- Lightweight Boot Loader Applied in Mobile and Embedded Devices
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded Devices
 
Arm processor architecture awareness session pi technologies
Arm processor architecture awareness session pi technologiesArm processor architecture awareness session pi technologies
Arm processor architecture awareness session pi technologies
 
Symbian OS With ARM Processor
Symbian OS With ARM ProcessorSymbian OS With ARM Processor
Symbian OS With ARM Processor
 
Sun Microsystems:Case Studyv1
Sun Microsystems:Case Studyv1Sun Microsystems:Case Studyv1
Sun Microsystems:Case Studyv1
 
Porting linux on ARM
Porting linux on ARMPorting linux on ARM
Porting linux on ARM
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORS
 
CPU Architectures for Mobile Phone Devices
CPU Architectures for Mobile Phone DevicesCPU Architectures for Mobile Phone Devices
CPU Architectures for Mobile Phone Devices
 
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...
 
BlackHat_DC_2011_Avraham_ARM Exploitation-wp.2.0
BlackHat_DC_2011_Avraham_ARM Exploitation-wp.2.0BlackHat_DC_2011_Avraham_ARM Exploitation-wp.2.0
BlackHat_DC_2011_Avraham_ARM Exploitation-wp.2.0
 

More from National Cheng Kung University

PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimePyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimeNational Cheng Kung University
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明National Cheng Kung University
 
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明National Cheng Kung University
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明National Cheng Kung University
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsNational Cheng Kung University
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationLecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationNational Cheng Kung University
 
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學National Cheng Kung University
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsF9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsNational Cheng Kung University
 
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明National Cheng Kung University
 

More from National Cheng Kung University (20)

PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimePyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtime
 
2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
 
Construct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoTConstruct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoT
 
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
 
從線上售票看作業系統設計議題
從線上售票看作業系統設計議題從線上售票看作業系統設計議題
從線上售票看作業系統設計議題
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisorXvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
Implement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVMImplement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVM
 
Priority Inversion on Mars
Priority Inversion on MarsPriority Inversion on Mars
Priority Inversion on Mars
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationLecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and Implementation
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded SystemsF9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
 
Open Source from Legend, Business, to Ecosystem
Open Source from Legend, Business, to EcosystemOpen Source from Legend, Business, to Ecosystem
Open Source from Legend, Business, to Ecosystem
 
Summer Project: Microkernel (2013)
Summer Project: Microkernel (2013)Summer Project: Microkernel (2013)
Summer Project: Microkernel (2013)
 
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
進階嵌入式系統開發與實作 (2013 秋季班 ) 課程說明
 

Recently uploaded

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 

Recently uploaded (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 

ARM and SoC Traning Part I -- Overview

  • 1. 探索嵌入式 ARM 平台與 SoC Part I – ARM 架構瀏覽 .SoC 平台 . 關鍵概念 Jim Huang (jserv) from 0xlab June 20, 2010 1 0xlab – connect your device to application – http://0xlab.org/
  • 2. Rights to copy © Copyright 2009­2010 0xlab.org contact@0xlab.org Corrections, suggestions, contributions and  translations are welcome! Attribution – ShareAlike 3.0 You are free to copy, distribute, display, and perform the work to make derivative works to make commercial use of the work Under the following conditions Attribution. You must give the original author credit. Share Alike. If you alter, transform, or build upon this work, you may distribute the  resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this  work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. License text: http://creativecommons.org/licenses/by­sa/3.0/legalcode 2 0xlab – connect your device to application – http://0xlab.org/
  • 3. 切入點 從軟體開發者的角度檢視 ARM 架構 善用開放原始碼軟體 GNU Toolchain – CodeSourcery 2009q1 QEMU 0.12.3 CuRT v1 ( 土製 ARM 即時作業系統 ) 參考 ARM SoC 平台: Marvell/Intel PXA255 作中學:觀察、系統模擬、驗證,動手 3 0xlab – connect your device to application – http://0xlab.org/
  • 4. Agenda ARM 架構快速瀏覽 ARM SoC 平台 關鍵概念: 工作模式、暫存器組、系統狀態、指令集、 例外處理 4 0xlab – connect your device to application – http://0xlab.org/
  • 5. ARM 架構快速瀏覽 ARM 歷史背景 ARM 的「家族」 ARM SoC 平台 關鍵概念: 工作模式、暫存器組、系統狀態、指令集、例外處理 5 0xlab – connect your device to application – http://0xlab.org/
  • 6. Part I 涵蓋範圍 6 0xlab – connect your device to application – http://0xlab.org/
  • 7. 無所不在的 ARM 7 Most of the above devides are powered by ARM. 0xlab – connect your device to application – http://0xlab.org/
  • 8. Darwin's Concept 適者生存 8 0xlab – connect your device to application – http://0xlab.org/
  • 9. 在 ARM 之前 BBC Micro (BBC Microcomputer System) 在 BBC (Britsh  Broadcasting Corporation) 主導的 BBC Computer Literacy  Project 中,設計一系列的電腦與週邊裝置。於 1980 年代已有 顯著的技術突破 《 The Computer Programme 》 , 1982  programming, graphics, sound and music, Teletext,  controlling external hardware and artificial intelligence ( 對 BBC Micro 的 ) 電腦供應商 Acorn Computers 升級其 Atom microcomputer 設計,是為 Proton ,提供更佳的圖形處 理與更快的 2 MHz MOS Technology 6502 CPU 1982 年,競爭對手 Sinclair 推出 ZX Spectrum ,嚴重威脅 Acrom 獲利 9 0xlab – connect your device to application – http://0xlab.org/
  • 10. ARM 就此展開 1983­1985 年間, Acorn Computers 推出第一款 ARM chip ,即 Acorn RISC Machine 。爾後該設計團隊於 1990 年代分後,公司命 名為 “ Advanced RISC Machine” (ARM) 成功取代 6502 processor 市場 ARM1 –  由 VLSI Technology, Inc. 製造晶圓生產 (1985)  ARM2 –  量產 (1986) 32­bit data bus, 26­bit address space (top 6 bits used as status flag) 16 32­bit registers (1 PC), 30,000 transistors No microcode, cache, Low power 國家半導體 NS 32016 的出現,威脅 Acorn 的獲利模式,隨後引發 財務危機, 1985 年,義大利設備商 Olivetti Ing et Cie 入主 ARM3 –  引入 4KB Cache, 25MHz (1989­1990) 10 0xlab – connect your device to application – http://0xlab.org/
  • 11. ARM1 Architect Steve Furber Roger Wilson Robert Heaton  Steve Furber  sfurber@cs.man.ac.uk Father of ARM 11 0xlab – connect your device to application – http://0xlab.org/
  • 12. ARM Ltd. 出現 1990 年代, Acorn 的財務狀況趨於穩定,亟欲轉型。該年 底,於英國劍橋,由 Apple, Acorn, VLSI 三家公司共同成立 ARM Ltd. ARM Ltd. 成立後,將 ARM3 的下一代命名為 ARM6 ,實體裝 置為 ARM600 稍候的 ARM610 用於 Apple Newton PDA(­1998) 1992 年底, 3DO 公司 ( 主要產品:遊戲機 ) 自 ARM Ltd. 取得 ARM 授權並成功量產電子設備,自此, ARM 在出售晶片設計 技術授權,獲得成功 目前採用 ARM 技術知識產權 (IP) 核心的微處理器,即我們常 所說的 ARM 微處理器 ARM 遍及工業控制、消費性電子產品、通信網路系統等領域 ARM7TDMI 是早期成功的 ARM core ,出貨量達數億單位 12 0xlab – connect your device to application – http://0xlab.org/
  • 13. ARM7TDMI 是早期成功的 ARM core ,出貨量達數億單位 StrongARM ARM9,920 MIPS 100 80 ARM8,810 60 ARM7TDMI ARM7D,7DM 40 ARM7,710 ARM Ltd. 成立後,將 ARM3 的下一代命名為 ARM6 , 20 ARM6,60,610 實體裝置為 ARM600 。稍候的 ARM610 用於 Apple  0 ARM2,3 Newton PDA(­1998) 1985 - 90 1991 1992 1993 1994 1995 1996 1997 13 0xlab – connect your device to application – http://0xlab.org/
  • 14. ARM 的 SWOT 分析 由 1990 年 12 月 18 日 ( 時值 ARM Ltd. 成立 21 日 ) 的內部文件,評估企業的 SWOT Strengths: 優勢 Weaknesses: 劣勢 Opportunities: 競爭市場的機會 Threats: 威脅 14 0xlab – connect your device to application – http://0xlab.org/
  • 16. ARM 的時代 DEC 自 ARM Ltd. 取得 ARM6 的授權,依據此基礎研發出 時脈可達 233MHz 的 StrongARM (SA­1x 系列 ) 使用於 PDA 裝置,如 HP iPAQ 500 mWatt of power @160MHz @.35µm DEC 後來為了與 Intel 控訴和解,將技術移轉到 Intel (1997) Intel 依據 StrongARM 的基礎,發展出 Xscale  StrongARM 關鍵的成員出走 Intel 後,成立 P.A. Semi  (Palo Alto Semiconducto)(2003) ,爾後被 Apple 併購 (2008) Intel 出售 XScale 產品線予 Marvell (2006) 16 0xlab – connect your device to application – http://0xlab.org/
  • 17. Dan Dobberpuhl Father of Alpha, StrongARM 17 0xlab – connect your device to application – http://0xlab.org/
  • 18. ARM 的「家族」 Architecture Versions ARM V3, V4, V5, V6, V7 使用 “ architecture” 一詞標注硬體設計架構 更具體來說,指的是 ISA (Instruction Set Architecture) Implementations ( 涉及不同的製程 ) ARM6 (1991), ARM7 (1995), ARM9 (1997) ARM10 (1999), ARM11 (2003) 使用 “ cores” 一詞標注其世代演進 18 0xlab – connect your device to application – http://0xlab.org/
  • 20. Application Note – Core Type & 0x41 A (ARM Ltd) Revision Identification, ARM 0x44 D (DEC) 0x69 I (Intel Corporation) Architecture / # cat /proc/cpuinfo / # cat /proc/cpuinfo version Processor Processor : ARMv7 Processor rev 3 (v7l) : ARMv7 Processor rev 3 (v7l) BogoMIPS BogoMIPS : 471.61 : 471.61 Features Features : swp half thumb fastmult vfp edsp thumbee neon : swp half thumb fastmult vfp edsp thumbee neon CPU implementer : 0x41 CPU implementer : 0x41 CPU architecture: 7 CPU architecture: 7 CPU variant CPU variant : 0x1 : 0x1 CPU part CPU part : 0xc08 : 0xc08 ARM ISA feature CPU revision CPU revision : 3 : 3 Hardware Hardware : : OMAP3 Beagle Board OMAP3 Beagle Board Revision Revision : : 0020 0020 Serial Serial : : 0000000000000000 0000000000000000 採用 ARM 技術知識產權 (IP) 核心的微處理器,即我們 常所說的 ARM 微處理器,實際的組態變化相當多元 20 0xlab – connect your device to application – http://0xlab.org/
  • 21. ARMv1 Implementation: 僅在原型機 ARM1 出現 指令集: 基本的資料處理指令 (ALU) ,不包含乘法指令 Byte, half­word, word 的 Load/Store 指令 跳躍 (jump/branch) 指令,包括 procedure call 軟體中斷 (SWI) 指令 定址空間: 64MB 21 0xlab – connect your device to application – http://0xlab.org/
  • 22. ARMv2 Implementation: ARM2 與 ARM3 (ARMv2a) 等硬體 指令集: 增加乘法和乘加指令 支援輔助運算器操作指令 快速中斷模式 (FIQ) SWP/SWPB 的最基本記憶體與暫存器交換指令 定址空間: 64MB (32­bit data bus, 26­bit address  space (top 6 bits used as status flag) 22 0xlab – connect your device to application – http://0xlab.org/
  • 23. ARMv2 :: SWP 在 ARM 暫存器組交換一個 word Two cycles R0 並確保 R1 single atomic action R2 Support for RT semaphores R7 R8 R15 23 0xlab – connect your device to application – http://0xlab.org/
  • 24. ARMv3 較大的改動,將定址空間增至 32­bit (4GB) 。 追加 CPSR 和 SPSR ,以利異常處理。增加 中止和未定義等兩種處理器模式 Implementation: ARM6 裝置範例: Apple Newton PDA 指令集: 增加 MRS/MSR 指令,存取新增的 Mi LDM CPSR/SPSR 暫存器 R0 Mi+1 R0 Mi+2 增加從異常處理返回的指令功能 R1 R1 MRS R2 R7 Mi+14 CPSR MSR R8 Mi+15 R14 SPSR STM R15 R14 24 0xlab – connect your device to application – http://0xlab.org/ R15
  • 25. ARMv3 :: Memory Addressing Byte : 8 bits alignment 相當重要,一些隱性的 Halfword : 16 bits 陷阱可參考拙作〈我是軟體,那些 must be aligned to 2­byte boundaries 處理器教我的事〉 (COSCUP 2008) Word : 32 bits must be aligned to 4­byte boundaries bit 31 bit 0 ARM address can be 32 bits long. Address refers to byte. 23 22 21 20 Address 4 starts at byte 4. 可在系統啟動時,調整為 little­ or  19 18 17 16 big­endian mode word16 bit 31 little­endian bit 0 15 14 13 12 half-word14 half-word12 byte 3 byte 2 byte 1 byte 0 11 10 9 8 word8 7 6 5 4 byte6 half-word4 bit 0 big­endian bit 31 byte address byte 0 byte 1 byte 2 byte 3 3 2 1 0 byte3 byte2 byte1 byte0 25 0xlab – connect your device to application – http://0xlab.org/
  • 26. ARMv4 廣泛應用的 ARM 架構,對 ARMv3 作進一步擴充,引入引 進了 16­bit Thumb 指令集 ( 可選擇 ) Implementation: ARM7, ARM9, StrongARM 裝置範例: GameBoy Advance, Nintendo DS, iPod, LEGO  NXT, Openmoko GTA01/GTA02 指令集: 增加 16­bit Thumb 指令集 加強軟體中斷 (SWI) 指令的功能 處理器系統模式引進特權方式 (SVC) 時,以 user 暫存 器操作 將未使用的指令空間,捕捉為未定義指令 26 0xlab – connect your device to application – http://0xlab.org/
  • 27. ARMv4 從 bus­structure 的角度來看 ARMv4 的 Implementation ARM7 : von Neumann architecture ARM9 : modified Harvard architecture 27 0xlab – connect your device to application – http://0xlab.org/
  • 28. ARMv4 :: ARM/Thumb 32­bit ARM Instruction  Sets 16­bit Thumb Instruction  Set 更高的指令集密度 對 cache 處理更有效率 All instructions are  executed as ARM Decompressor converts  Thumb to equivalent ARM  instruction Decompressor present in  the decode stage of the  pipeline. 28 0xlab – connect your device to application – http://0xlab.org/
  • 29. ARMv5 Implementation: ARM10, Xscale 裝置範例: HTC Dream (Google G1 Phone) 指令集: BLX 指令 (Improved ARM and Thumb interworking) CLZ 指令 (count leading­zeroes) BRK 中斷指令 增加 DSP 強化指令 (v5TE) E – enhanced DSP instructions including saturated arithmetic  operations and 16­bit multiply operations 增加 Jazelle 指令集 J – support for new Java state, offering hardware and  optimized software acceleration of bytecode execution. 為 co­processor 增加更多可選擇的指令 29 0xlab – connect your device to application – http://0xlab.org/
  • 30. ARMv5 :: DSP Extension (E) 30 0xlab – connect your device to application – http://0xlab.org/
  • 31. ARMv5 :: co­processor Marvell/Intel Xscale Wireless MMX co­processor 概念:將 x86 行之有年的 MMX/SSE 指令集設計概念,應用於 Xscale 處理 器,以 co­processor 的形式存在 ARM 的架構最多可支援 16 個 co­processor ,以 Xscale 為例: co­processor 0 co­processor 1 Xscale co­processor instructions Coprocessor data transfers Coprocessor data operations Coprocessor register load and store ARM Co-processor Core 31 0xlab – connect your device to application – http://0xlab.org/
  • 32. ARMv6 Implementation: ARM11 裝置範例: Apple iPhone (1st/2nd) 指令集 / 特性: 引入 60 個以上新的 SIMD(Single Instruction Multiple  Data) ,使多媒體處理速度快 1.75 倍 提出新的 atomic operations(LDREX/STREX) 避免 swp 指令的限制 改進記憶體管理,使系統性能提高 30% 強化 Mixed­Endian 支援 (Little­Endian OS + Bit­Endian  Data for TCP/IP) 改進 unaligned data 支援,進一步提昇字串操作的效能 32 0xlab – connect your device to application – http://0xlab.org/
  • 33. ARMv6 :: SIMD Extensions 33 0xlab – connect your device to application – http://0xlab.org/
  • 34. ARMv6 :: Endianness Support (E bit) 34 0xlab – connect your device to application – http://0xlab.org/
  • 35. ARMv6 :: Byte Reverse instruction 35 0xlab – connect your device to application – http://0xlab.org/
  • 36. ARMv6 :: unaligned access  Test on BeagleBoard 500 MHz + 0xdroid (0xlab's Android distribution) mmemcpy_use_unaligned :  (16 bytes copy) =  167.4 MB/s /  368.7 MB/s memcpy :                 (16 bytes copy) =  137.0 MB/s /  352.5 MB/s mmemcpy_use_unaligned :  (24 bytes copy) =  231.3 MB/s /  552.7 MB/s memcpy_neon :            (24 bytes copy) =  199.3 MB/s /  350.5 MB/s mmemcpy_use_unaligned :  (31 bytes copy) =  315.6 MB/s /  714.2 MB/s memcpy :                 (31 bytes copy) =  267.9 MB/s /  375.6 MB/s 36 0xlab – connect your device to application – http://0xlab.org/
  • 37. ARMv7 Implementation: Cortex­A8 第一個 ARMv7 ISA 的完整 implementation ,包含 Advanced  SIMD Media Extension (NEON) 自 ARMv7 起, core 命名改以 Cortex 開頭 In­order, dual­issue superscalar core 13­stage integer pipeline 10­stage NEON media pipeline Dedicated L2 with 9­cycle latency Branch predictor based on global history NEON: 64/128­bit SIMD, 2x­4x ↑ over prior ARMv6 SIMD ARMv7 關鍵特性 引入 Thumb­2, Thumb­EE (for dynamic/JIT compiler) 對應的 Implementation 時脈達 1 GHz 功耗小於 300mW <  4mm2 at 65nm ( 不含 NEON, L2 cache, ETM) 37 0xlab – connect your device to application – http://0xlab.org/ Source: Williamson of ARM at Fall processor Forum 05
  • 38. ARMv7 :: NEON 64/128­bit 混合式 SIMD 架構 D0 Q0 D1 Two aliased register files  D2 Q1 32 x 64­bit (D0­D31) D3 16 x 128­bit (Q0­Q15) Shared with VFP D30 Integer and SP FP processing D31 Q15 8, 16, 32, 64­bit integers Encoded in ARM and Thumb­2 Alias, same physical structure 64­bit D1.U8 D0.U8 Q0.F32 128­bit 38 0xlab – connect your device to application – http://0xlab.org/ Source: Grisenthwaite of ARM
  • 39. vadd.I16 D0, D1, D2 vmul.I32.S16 Q0, D2, D3 D1 D2 D2 D3 + + + + * * * * D0 Q0 64b 128b vshr.I16.I32 D0, Q1, #5 128b Q1 #5 >> >> >> >> D0 39 0xlab – connect your device to application – http://0xlab.org/ Source: Grisenthwaite of ARM
  • 40. NEON Load or store 1­element or 2, 3, 4­elelment structure Handle complex number, coordinates, etc. Easy AoS to SoA X0 vld3.16 {D0, D1, D2}, [R0]! Y0 X3 X2 X1 X0 D0 Z0 Y3 Y2 Y1 Y0 D1 X1 Y1 Z3 Z2 Z1 Z0 D2 vst3.16 {D0, D1, D2}, [R0]! Z1 • No data swizzling needed! • Fewer instruction, higher performance 40 0xlab – connect your device to application – http://0xlab.org/
  • 41. ARMv7 :: Thumb­2 大幅改進 Thumb 指令集的限制 Thumb 的空間使用 ARM 的效能 引入混合 16­/32­bit 指令集的並存模式 不再需要繁瑣的狀態轉換 兼顧效能與程式碼密度 41 0xlab – connect your device to application – http://0xlab.org/ 41
  • 42. ARM core performance roadmap ARM Cortex Release “Intelligent Computing” Adv Development 2500 2000 Cortex­A8 "Tiger"  1500 DMIPS 1000 x4 750 ARM1176JZF­S™ ARM11 MPCore ARM1136EJ­S™ 500 ARM1026EJ­S™ 250 ARM926EJ­S™ Pre­2005 2005 2006 Source: Williamson of ARM at Fall processor Forum 05 42 0xlab – connect your device to application – http://0xlab.org/
  • 43. Cortex­A8 NEON Performance • Cortex­A8 NEON performance vs. ARMv5 and ARMv6 implementations 1x 2x 3x 4x MPEG­4   GSM­AMR   MP3 Decoder   ARM926EJ­S   ARM1136J­S   Cortex­A8   ARMv5TE ARMv6 NEON • CPU bandwidth required for various applications: – MPEG4 VGA decode1  275 MHz – MP3 decode, 320kbps 48kHz, worst case2      9.8 MHz – “Quake 2­like” application, CIF resolution3 300 MHz – H.264 (estimated) 350 MHz 1) MPEG­4 Simple Profile @ 30fps 512kbps , 133MHz SDRAM 10­1­1­1 memory 2) MP3 Decoder @ 320kbps 48kHz (worst case means cold start on context switch), 133MHz SDRAM 10­1­1­1 memory 3) Quake2­like simulator, full software graphics pipeline, FP implementation 133MHz SDRAM 10­1­1­1 memory Source: ARM Developer conference 43 0xlab – connect your device to application – http://0xlab.org/
  • 45. ARM 架構快速瀏覽 ARM SoC 平台 關鍵概念: 工作模式、暫存器組、系統狀態、指令集、例外處理 45 0xlab – connect your device to application – http://0xlab.org/
  • 46. SoC (System­on­Chip) 整合多種不同功能的複雜 IC 組合,針對特定的市場或應用需求 典型的組成 Programmable processor On­chip memory HW accelerating function units (DSP) Peripheral interfaces (GPIO) Embedded software 46 0xlab – connect your device to application – http://0xlab.org/
  • 47. 典型的硬體介面 I/O 裝置藉由 memory­mapped register 溝通 DMA 與 interrupt 是選擇性的 other devices Memory I/O device I/O device Interrupt Databus controller Address bus Direct Memory CPU Access (DMA) Controller IRQ FIQ other devices 47 0xlab – connect your device to application – http://0xlab.org/
  • 48. CPU 與 I/O 典型有兩種對應方式: I/O mapped I/O I/O 與 memory 均擁有自己的記憶體空間 需要特別的指令來處理 I/O Memory mapped I/O I/O 與 memory 共用記憶體空間 不需特別指令來處理 I/O 48 0xlab – connect your device to application – http://0xlab.org/
  • 49. Memory­Mapped I/O FFFF FFFF Memory I/O 0 0 R1=1234 sta r0,r1 ;; 寫入 mem address 1234 out r0,r1 ;; 寫入 I/O address 1234 2345 FFFF FDD 2345 HD I/O LCD 1234 . . 0 1234 R0=‘A’, R1=1233, R2=1234 ( 假設 1234 為 LCD 的 MMIO 位址 ) str r0, [r1,#0]  ;;addr 1234 =‘A’ str r0, [r2,#0]  ;;LCD 顯示‘ A’ 49 0xlab – connect your device to application – http://0xlab.org/
  • 50. SoC  實例 50 0xlab – connect your device to application – http://0xlab.org/
  • 51. Display Driver IC: TFT, OLED Camera Chipset: CMOS - CCD Connectivity: WLAN, GPS, Bluetooth Processor: ARM Modem: GSM/GPRS, WCDMA SoC RF/Analog: Rx/Tx, Zero IF RAM: Mobile DRAM, SRAM, UtRAM Smart Card: SIM SIP / MCP Flash Memory: Code/Data Storage 51 0xlab – connect your device to application – http://0xlab.org/
  • 52. Modem Chip Evolution for Cellular Phone 52 0xlab – connect your device to application – http://0xlab.org/
  • 53. Moble station :: Baseband 53 0xlab – connect your device to application – http://0xlab.org/
  • 54. Moble station :: Software WAP Applications (GVM, Wavelet, M-Commerce, LBS..) Browser G-APIs Mobile Platform T-APIs Protocol Radio Comm. APP Manager Stack Interface I/O Device Driver Radio Telephony Device Control (HW Abstraction Layer) (CDMA/GSM/GPRS/WCDMA) Embedded OS (REX, VxWorks, Symbian) Embedded HW 54 0xlab – connect your device to application – http://0xlab.org/
  • 55. ARM On­Chip Bus On­Chip ARM Core RAM UART PIO AHB/ASB APB Memory  Bridge Interface DMA Master Timer Keypad A typical AMBA system AHB: Advanced High-performance Bus ASB: Advanced System Bus APB: Advanced Peripheral Bus ** AMBA: Advanced Microcontroller Bus Architecture 55 0xlab – connect your device to application – http://0xlab.org/
  • 56. Example: GPRS Phone 56 0xlab – connect your device to application – http://0xlab.org/
  • 57. Example: Videophone 57 0xlab – connect your device to application – http://0xlab.org/
  • 58. ARM 架構快速瀏覽 ARM 歷史背景 ARM 的「家族」 ARM SoC 平台 關鍵概念: 工作模式、暫存器組、系統狀態、指令 集、例外處理 探討 PXA255 SoC 為例 觀察 CuRT 的運作並驅動 UART 裝置 58 0xlab – connect your device to application – http://0xlab.org/
  • 59. 善用強大的系統模擬器 QEMU 不只是「窮人的 ARM 開發板」 ( 中國北京清華大學 Skyeye 開發團隊的故事 ) 對於學習 / 分析 ARM 架構與指令集,提供一個高 整合度的互動環境 內建 instruction­level tracer gdb server 的整合 豐富的週邊硬體模擬 Android SDK/Emulator 的 goldfish 虛擬硬體平台 後續的實驗部份皆以 QEMU 模擬硬體環境 59 0xlab – connect your device to application – http://0xlab.org/
  • 60. 豐富的硬體模擬環境 Openmoko GTA01/GTA02 emulated by QEMU ARMv4t / Samsung S3C2410/2442 Sharp PDAs emulated by QEMU  ARMv5te / Marvell PXA2xx ARM Versatile PB board emulated by QEMU ARM926ej Gumstix ARMv5te / Marvell PXA25x (hardware model: connex) 60 0xlab – connect your device to application – http://0xlab.org/
  • 61. Emulated by QEMU Serial / JTAG / TCP-IP 61 0xlab – connect your device to application – http://0xlab.org/
  • 62. QEMU 回顧 (1) 快速的模擬器: Portable dynamic translator 完整系統模擬 instruction set + processor + peripherals 硬體平台: x86, x86_64, ppc, arm, sparc, mips, nds( 台灣心 ) 指定特定機器: qemu­system­arm ­M ? 兩種模擬模式: User, System 關於 QEMU 的原理,可參考拙作〈 QEMU JIT 62 Code Generator & System Emulation 〉 0xlab – connect your device to application – http://0xlab.org/
  • 63. QEMU 回顧 (2) 兩種執行模式 user mode emulation :可執行非原生架構之應用程式 支援: x86, ppc, arm, sparc, mips system emulation qemu linux.img 也可分別指定 kernel image 、 initrd ,及相關參數 以 xscale 為例: ~/poky/build/tmp$ file ./rootfs/bin/busybox 使用 ARM target 的 ld-linux.so.2 ./rootfs/bin/busybox: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, stripped ~/poky/build/tmp$ ./qemu-arm ./rootfs/lib/ld-linux.so.2 --library-path ./rootfs/lib ./rootfs/bin/busybox uname -a Linux venux 2.6.20-12-generic #2 SMP Sun Mar 18 03:07:14 UTC 2007 armv5tel unknown Processor 變成 armv5te (Xscale) 63 0xlab – connect your device to application – http://0xlab.org/
  • 64. QEMU 回顧 (3) gdb stub 考慮在 system emulation 模式下,該如何喚起 gdb ? Remote Debugging : gdb 可透過 serial line 或 TCP/IP 進行遠端除錯 gdb stub 開發平台 (Host) 運作完整的 GDB Qemu 所模擬的機器 64 0xlab – connect your device to application – http://0xlab.org/
  • 65. QEMU 回顧 (4) gdb stub :透過 TCP/IP (gdb) target remote localhost:1234 qemu 執行選項: ­s  Wait gdb connection to port 1234. ­S  Do not start CPU at startup localhost:1234 gdb stub 開發平台 (Host) 運作完整的 GDB Qemu 所模擬的機器 65 0xlab – connect your device to application – http://0xlab.org/
  • 66. [PLAN] 將自製的 CuRT 作業系統運作於 PXA255 (emulated by QEMU) , 透過 gdb stub 及 TCP/IP ,與 host 端進行 Remote debugging # dd of=flash­image bs=1k count=16k if=/dev/zero # dd of=flash­image bs=1k conv=notrunc if=curt_image.bin # qemu­system­arm ­M connex ­pflash flash­image ­serial stdio ­s ­S wait gdb connection to port 1234. CuRT 後續維護 (by cyt93cs) CuRT 原始程式碼: (BSD 授權 ) http://code.google.com/p/curt­v1­rework/ http://jserv.sayya.org/kernel/ Emulated by QEMU Serial / JTAG / TCP-IP 66 0xlab – connect your device to application – http://0xlab.org/
  • 67. CuRT 準備動作 (1) # cd app/shell 取得 CodeSourcery GNU Toolchain 2009q1 # make 解開安裝於 /usr/local/csl 目錄下 於兩個 X 終端機視窗設定必要的 $PATH 環境變數 … ( 參考的編譯畫面 ) ... arm­none­linux­gnueabi­ld ­nostdlib ­static ­e _start ­p ­­no­undefined ­X ­T ld­ script.lds  ­o curt_image.elf  ./main.o ../../device/serial.o ../../lib/stdio.o ../../arch/arm/mach­ pxa/port.o ../../arch/arm/mach­pxa/start.o ../../arch/arm/mach­pxa/asm_port.o  ../../kernel/kernel.o ../../kernel/thread.o ../../kernel/list.o  ../../kernel/sync.o ../../kernel/ipc.o arm­none­linux­gnueabi­objcopy ­O binary ­R .note ­R .note.gnu.build­id ­R .comment ­S  curt_image.elf curt_image.bin #  檔案 curt_image.elf 為包含除錯資訊的 ELF 執行檔 67 0xlab – connect your device to application – http://0xlab.org/
  • 68. CuRT 準備動作 (2) # ./prepare_flash # ./run­on­connex­debug # cgdb ­d arm­none­linux­gnueabi­gdb curt_image.elf cgdb 是 CURSES 介面撰寫的 GNU GDB 前端,有著類似 vim 的操作環境 預先載入 CuRT 的除錯資訊檔案 68 0xlab – connect your device to application – http://0xlab.org/
  • 69. CuRT 準備動作 (3) 因為 qemu 啟動時加上 ­s ­S 參數,會 等待 remote gdb 連線才會繼續執行 QEMU ( 在 QEMU 視窗出現後,按下 Ctrl­Alt­2 組合鍵,可切換到 QEMU monitor 畫面 ) (gdb) target remote :1234 一旦 qemu 視窗出現,即可準備 remote gdb 連線,在 cgdb 下方 視窗敲入指令 連線到 qemu 後,按下 'c'  要求 繼續執行 69 0xlab – connect your device to application – http://0xlab.org/
  • 70. QEMU monitor ( 在 QEMU 視窗出現後,按下 Ctrl­Alt­2 組合鍵,可切換到 QEMU monitor 畫面 ) (qemu) info registers 在 gdb 中按下 Ctrl-C 組合鍵以搶得控制權 static void shell_thread_func(void *pdata){     …   While (1) {         ...         gets(buf); Debugger 70 0xlab – connect your device to application – http://0xlab.org/
  • 71. QEMU monitor (qemu) info registers R00=00000000 R01=00000020 R02=00000020 R03=00000000 R04=04040404 R05=05050505 R06=06060606 R07=07070707 R08=08080808 R09=09090909 R10=10101010 R11=a000c438 R12=12121212 R13=a000c42c R14=a0001828 R15=a0000bbc PSR=60000013 ­ZC­ A svc32 r0 r8 r1 r9 31 0 r2 r10 r3 r11 CPSR r4 r12 ARM r5 r13 – Z C –  Registers r6 r14 71 r7 r15 (PC) 0xlab – connect your device to application – http://0xlab.org/
  • 72. QEMU monitor Processor Mode svc : supervisor r0 r8 r1 r9 r2 r10 r3 r11 r4 r12 ARM r5 r13 Regs r6 r15 (PC) r14 72 r7 0xlab – connect your device to application – http://0xlab.org/
  • 73. Basic Processor Modes User (usr) – Normal program execution modes FIQ (fiq) – Support a high­speed data transfer or channel  process IRQ (irq) – Used for general­purpose interrupt handling Supervisor (svc) – A protected mode for OS entered on reset and when a Software Interrupt    instruction executed. Abort (abt) – Implements VM and/or memory protection Undefined (und) – Support software emulation of HW  coprocessors System: sys – Run privileged OS tasks fiq, irq, svc, abt, und – exception modes 73 0xlab – connect your device to application – http://0xlab.org/
  • 74. Interrupt 是 Exception 的特例 74 0xlab – connect your device to application – http://0xlab.org/
  • 75. r0 r8 r1 r9 31 0 r2 r10 r3 r11 CPSR r4 r12 r5 r13 N Z C V r6 r14 r7 r15 (PC) Link register unbanked registers banked registers Every arithmetic, logical, or shifting operation may set CPSR  (current program statues register) bits: N (negative), Z (zero), C (carry), V (overflow). Examples:  ­1 + 1 = 0:  NZCV = 0110. 231­1+1 = ­231:  NZCV = 0101. 75 0xlab – connect your device to application – http://0xlab.org/
  • 76. ARM Register Set Current Visible Registers Current Visible Registers r0 r0 Undef Mode Abort SVC Mode IRQ Mode UserMode FIQ Mode r1 r1 r2 r2 r3 r3 Banked out Registers Banked out Registers r4 r4 r5 r5 r6 r6 User User FIQ IRQ IRQ SVC SVC Undef Undef Abort Abort r7 r7 r8 r8 r8 r8 r9 r9 r9 r9 r10 r10 r10 r10 r11 r11 r11 r11 r12 r12 r12 r12 r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r15 (pc) r15 (pc) cpsr cpsr spsr spsr spsr spsr spsr spsr spsr spsr spsr spsr spsr 76 0xlab – connect your device to application – http://0xlab.org/
  • 77. ARM Register Set – All modes User FIQ IRQ SVC Undef Abort r0 r1 User r2 mode r3 r0-r7, r4 r15, User User User User Thumb state and r5 mode mode mode mode cpsr r0-r12, r0-r12, r0-r12, r0-r12, Low registers r6 r15, r15, r15, r15, r7 and and and and r8 r8 cpsr cpsr cpsr cpsr r9 r9 r10 r10 Thumb state r11 r11 High registers r12 r12 r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r15 (pc) cpsr spsr spsr spsr spsr spsr Note: System mode uses the User mode register set 77 0xlab – connect your device to application – http://0xlab.org/
  • 78. ARM Registers ARM 有 37 個暫存器,皆為 32­bit 長度 1 個專屬的 PC (program counter) 1 個專屬的 CPSR (current program status register) 5 個專屬的 SPSR ( saved program status registers) 30 個通用的暫存器 規劃 通用組 : r0­r12 registers 挪作特別使用 : r13 (stack pointer, sp), r14 (link register, lr)  program counter, r15 (pc) 故實際僅有 16 個可見的暫存器 78 0xlab – connect your device to application – http://0xlab.org/
  • 79. IRQ and FIQ  • Program Status Register  31 30 29 28 27 … 8 7 6 5 4 3 2 1 0 N Z C V I F M4 M3 M2 M1 M0 – 若要抑制 interrupts ,將 "F” 或 “ I” bit 設定為 1  • 一旦 interrupt 觸發,處理器將變更至 FIQ32_mode registers  或 IRQ32_mode registers  • Switch register banks  • Copies CPSR to SPSR_mode (saves mode, interrupt flags, etc.) • Changes the CPSR mode bits (M[4:0]) • Disables interrupts  • Copies PC to R14_mode (to provide return address) • Sets the PC to the vector address of the exception handler  79 0xlab – connect your device to application – http://0xlab.org/
  • 80. Interrupt Handlers  • 當 interrupt 發生時,硬體會跳躍到 interrupt handler time user program user program Task IRQ Interrupt handler IRQ FIQ • On interrupt, the processor will set the  corresponding interrupt bit in the CPSR to  Interrupt disable subsequent interrupts of the  same type from occurring.  • However, interrupts of a higher priority  can still occur. 80 0xlab – connect your device to application – http://0xlab.org/
  • 81. Nested/Re­entrant Interrupts  • 但是, interrupts 也可能在執行 interrupt handlers 時 被觸發,此為 nested( 巢狀 ) interrupt time user program user program Task IRQ Interrupt handler IRQ FIQ Interrupt handler FIQ • On interrupt, the processor will set the  Interrupt corresponding interrupt bit in the CPSR to  disable subsequent interrupts of the  same type from occurring.  Second • However, interrupts of a higher priority  Interrupt can still occur. 81 0xlab – connect your device to application – http://0xlab.org/
  • 82. Timing of Interrupts  • 在 interrupt handler 實際運作前,必須保存目前程 式 (context) 的 register ( 若觸及這些 register)  • 這也是何以 FIQ 需要額外 register 的緣故,為了 降低 CPU 保存 context 的成本開銷 time user program user program cpu context saved Task IRQ “servicing” interrupt FIQ cpu context restored Interrupt latency Interrupt Interrupt response 82 0xlab – connect your device to application – http://0xlab.org/
  • 83. Michael Jordan said... I can accept failure. Everyone fails at something. But I cannot accept not trying. 在 Part II 議程中,將會以 CuRT 為例,探討前述觀念 的實務 繼續探索 PXA255 SoC 83 0xlab – connect your device to application – http://0xlab.org/
  • 85. PXA255 Function Block RTC Memory OS Timer Controller PWM(2) 0x4400_0000 PCMCIA & CF XCVR Interrupt Control Controller Socket 0, 1 Clock & System Bus Power Man. Dynamic SDRAM/ I2S Memory SMROM Control 4 banks I2C Megacell AC97 Write Read Core Buffer Buffer FF_UART BT_UART Variable Load/Store Data Latency s u Bl ar e hp r e P Slow lrDA I/O ASIC Dcache Addr O/ I es op uPl ar e ne G DMMU Control i Fast lrDA (32 Kbytes) SSP Minicache XScale CS Core #3,4,5 NSSP Icache PC IMMU ROM/ (32 Kbytes) Static USB Memory Flash Instructions r Client Control SRAM 4 banks MMC 3.6864 MHz 32.768 KHz Osc Osc CS #0,1,2 Color or Grayscale LCD Controller 85 0xlab – connect your device to application – http://0xlab.org/
  • 86. PXA255 Memory Model MMU On-chip Core Caches Buffers Memory Memory Controller Physical Addresses Virtual Addresses http://www.intel.com/design/pca/prodbref/252780docs.htm 86 0xlab – connect your device to application – http://0xlab.org/
  • 87. Memory Map 0hFFFF FFFF Reserved (1280 Mbytes) 0hB000 0000 SDRAM Bank 3 (64 Mbytes) 0hAC00 0000 SDRAM Bank 2 (64 Mbytes) Dynamic Memory Interface 0hA800 0000 256 Mbytes SDRAM Bank 1 (64 Mbytes) 0hA400 0000 SDRAM Bank 0 (64 Mbytes) 0hA000 0000 Reserved (1344 Mbytes) 0h4C00 0000 Memory Mapped registers (Memory Control) 0h4800 0000 Memory Mapped registers Interface Memory Mapped registers (LCD) 0h4400 0000 192 Mbytes Memory Mapped registers (Peripherals) 0h4000 0000 PCMCIA/CF - Slot 1 (256 Mbytes) 0h3000 0000 PCMCIA Interface 512 Mbytes PCMCIA/CF - Slot 0 (256 Mbytes) 0h2000 0000 Reserved (128 Mbytes) 0h1800 0000 Static Chip Select 5 (64 Mbytes) 0h1400 0000 Static Chip Select 4 (64 Mbytes) 0h1000 0000 Static Chip Select 3 (64 Mbytes) Static Memory Interface (ROM, Flash, 0h0C00 0000 Static Chip Select 2 (64 Mbytes) SRAM) 384 Mbytes 0h0800 0000 0h0400 0000 Static Chip Select 1 (64 Mbytes) 0x4000000-0x4C00000 之間的 Memory Mapped 區域 Static Chip Select 0 (64 Mbytes) 0h0000 0000 87 0xlab – connect your device to application – http://0xlab.org/
  • 88. Memory Map 在 SoC 上,週邊 (peripheral) 被對應到 0hFFFF FFFF Reserved (1280 Mbytes) 特定的記憶體區段,直接操作該記憶體, 0hB000 0000 SDRAM Bank 3 (64 Mbytes) 即可控制週邊硬體裝置 0hAC00 0000 SDRAM Bank 2 (64 Mbytes) MMIO (Memory-Mapped Input/Output) Dynamic Memory Interface 0hA800 0000 256 Mbytes SDRAM Bank 1 (64 Mbytes) 0hA400 0000 SDRAM Bank 0 (64 Mbytes) 0hA000 0000 Reserved (1344 Mbytes) 0h4C00 0000 Memory Mapped registers (Memory Control) 0h4800 0000 Memory Mapped registers Memory Mapped registers (LCD) 0h4400 0000 Interface Memory Mapped registers (Peripherals) 0h4000 0000 192 Mbytes PCMCIA/CF - Slot 1 (256 Mbytes) 0h3000 0000 PCMCIA Interface 512 Mbytes PCMCIA/CF - Slot 0 (256 Mbytes) 0h2000 0000 Reserved (128 Mbytes) 0h1800 0000 Static Chip Select 5 (64 Mbytes) 0h1400 0000 Static Chip Select 4 (64 Mbytes) 0h1000 0000 Static Chip Select 3 (64 Mbytes) Static Memory Interface (ROM, 0h0C00 0000 0h0800 0000 Static Chip Select 2 (64 Mbytes) Flash, Static Chip Select 1 (64 Mbytes) SRAM) 384 Mbytes 0h0400 0000 Static Chip Select 0 (64 Mbytes) 0h0000 0000 對 PXA255 來說,即 0x0x4000000-0x4400000 88 0xlab – connect your device to application – http://0xlab.org/
  • 89. PXA255 core Function Diagram UDC- L_DD(15:0) Serial Channel 0 (USB) UDC+ L_FCLK RXD_1 L_LCLK Serial Channel 1 L_PCLK LCD Control TXD_1 RXD_2 L_BIAS Serial Channel 2 (IrDA) TXD_2 GP(27:0) nCAS/ DQM(3:0) GPIO Ports RXD_3 Serial Channel 3 (UART) TXD_3 nRAS/ nSDCS(3:0) TXD_C nOE RXD_C nWE Serial Channel 4(CODEC) SFRM_C nCS(5:0) RDY Memory Control SCLK_C BATT_FAULT nSDRAS Intelⓡ VDD_FAULT nSDCAS Power Management XScale* PWR_EN PXA 250 SDCKE<1:0> [256-pins] SDCLK<2:0> TCK_BYP RD/nWR TESTCLK Transceiver Control nPOE PEXTAL nPWE PXTAL nPIOR nPIOW TEXTAL nPCE<2:1> TXTAL PSKTSEL PCMCIA Bus Signals Clocks, Reset and Test nPREG nRESET nPWAIT nRESET_OUT nIOIS16 SMROM_EN A<25:0> Address Bus ROM_SEL TCK TDI D<31:0> Data Bus TDO VDD JTAG TMS VDDX nTRST VSS/VSSX Supply 89 0xlab – connect your device to application – http://0xlab.org/
  • 90. PXA255 Serial/UART UDC- L_DD(15:0) Serial Channel 0 UDC+ L_FCLK (USB) RXD_1 L_LCLK Serial Channel TXD_1 L_PCLK LCD Control 1 RXD_2 L_BIAS Serial Channel 2 TXD_2 GP(27:0) (IrDA) RXD_3 nCAS/ DQM(3:0) GPIO nRAS/ nSDCS(3:0) Ports Serial Channel 3 TXD_3 (UART) TXD_C nOE RXD_C nWE Serial Channel SFRM_C nCS(5:0) RDY Memory 4(CODEC) SCLK_C Control BATT_FAULT nSDRAS Intelⓡ VDD_FAULT nSDCAS Power Management XScale* PWR_EN SDCKE<1:0> PXA 250 Universal Asynchronous Receiver/Transmitter (UART): controller TCK_BYP [256-pins] SDCLK<2:0> RD/nWR TESTCLK Transceiver nPOE PEXTAL nPWE Control PXTAL nPIOR nPIOW TEXTAL nPCE<2:1> TXTAL PSKTSEL PCMCIA Bus Clocks, Reset and nPREG Signals Test nRESET nRESET_OUT Terminal nPWAIT nIOIS16 Parallel­to­Serial TX Parallel­to­SerialROM_SEL SMROM_EN RX A<25:0> Address Bus Converter Converter TCK D<31:0> Data Computer CPU TDI CPU JTAG TDO TMS VDD VDDX Bus Serial­to­Parallel RX TX Supply Serial­to­Parallel nTRST VSS/VSSX Converter Converter Serial Link 90 0xlab – connect your device to application – http://0xlab.org/
  • 91. UDC- L_DD(15:0) Serial Channel 0 UDC+ L_FCLK (USB) RXD_1 L_LCLK Serial Channel TXD_1 L_PCLK LCD Control 1 RXD_2 L_BIAS Serial Channel 2 TXD_2 GP(27:0) (IrDA) RXD_3 nCAS/ DQM(3:0) GPIO nRAS/ nSDCS(3:0) Ports Serial Channel 3 TXD_3 (UART) TXD_C nOE RXD_C nWE Serial Channel SFRM_C nCS(5:0) RDY Memory 4(CODEC) SCLK_C Control BATT_FAULT nSDRAS Intelⓡ VDD_FAULT nSDCAS Power Management XScale* SDCKE<1:0> Universal Asynchronous Receiver/Transmitter PWR_EN PXA 250 SDCLK<2:0>  (UART): controller TCK_BYP [256-pins] RD/nWR TESTCLK Transceiver nPOE PEXTAL nPWE Control PXTAL nPIOR nPIOW TEXTAL nPCE<2:1> TXTAL PSKTSEL PCMCIA Bus Clocks, Reset and nPREG Signals nRESET Test nPWAIT nRESET_OUT nIOIS16 SMROM_EN Address Bus A<25:0> ROM_SEL TCK TDI D<31:0> Data TDO VDD JTAG TMS VDDX Bus nTRST VSS/VSSX Supply FFUART (Full function UART) 的 (memory mapped) base address 為 0x40100000 91 0xlab – connect your device to application – http://0xlab.org/
  • 92. Data Communication  • 透過 serial line 建立電腦與終端機模擬程式的通訊 – Data is converted from parallel (bytes) to serial (bits) in the bus  interface  – Bits are sent over wire (TX) to terminal (or back from terminal to  computer)  – Receiving end (RX) translates bit stream back into parallel data  (bytes)  Terminal Parallel­to­Serial TX Parallel­to­Serial RX Converter Converter Computer CPU CPU Serial­to­Parallel RX Serial­to­Parallel TX Converter Converter Serial Link 92 0xlab – connect your device to application – http://0xlab.org/
  • 93. Serial Port  RxRegister 0 1 2 3 4 5 6 7 RxRegister 0 1 2 3 4 5 6 7 FIFO Buffer FIFO Buffer 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Clock Clock 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 FIFO Buffer FIFO Buffer TxRegister TxRegister 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Processor Peripheral 93 0xlab – connect your device to application – http://0xlab.org/
  • 94. Sample shell for CuRT CuRT_v1/app/shell/main.c CuRT_v1/app/shell/main.c int main() int main() { { SerialInit(); SerialInit(); init_interrupt_control(); init_interrupt_control(); init_curt(); init_curt(); ... ... shell_tid = thread_create(&shell_thread, shell_tid = thread_create(&shell_thread, &thread_stk[0][THREAD_STACK_SIZE-1], &thread_stk[0][THREAD_STACK_SIZE-1], shell_thread_func, shell_thread_func, "shell_thread", "shell_thread", 5, NULL); 5, NULL); CuRT_v1/app/shell/main.c CuRT_v1/app/shell/main.c static void shell_thread_func(void *pdata) static void shell_thread_func(void *pdata) { { ... ... char buf[80] = { '0' }; char buf[80] = { '0' }; while (1) { while (1) { printf("$ "); printf("$ "); gets(buf); gets(buf); printf("n"); printf("n"); ... ... else if (!strcmp(buf, "stat")) { else if (!strcmp(buf, "stat")) { thread_resume(stat_tid); thread_resume(stat_tid); 94 0xlab – connect your device to application – http://0xlab.org/
  • 95. Serial “Driver” in CuRT CuRT_v1/device/serial.c CuRT_v1/device/serial.c void SerialInit(void) void SerialInit(void) { { /* GP39, GP40, GP41 UART(10) */ /* GP39, GP40, GP41 UART(10) */ GAFR1_L |= 0x000A8000; GAFR1_L |= 0x000A8000; GPDR1 |= 0x00000380; GPDR1 |= 0x00000380; /* 8-bit, 1 stop, no parity */ /* 8-bit, 1 stop, no parity */ rFFLCR = 0x00000003; rFFLCR = 0x00000003; /* Reset tx, rx FIFO. clear. FIFO enable */ /* Reset tx, rx FIFO. clear. FIFO enable */ rFFFCR = 0x00000007; rFFFCR = 0x00000007; /* UART Enable Interrupt */ /* UART Enable Interrupt */ rFFIER = 0x00000040; rFFIER = 0x00000040; 對 PXA255 之 FF_UART (Full Function UART) 作初始化 XScale FF_UART Core r e hp r e P 95 i 0xlab – connect your device to application – http://0xlab.org/