• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    [Redboot]ecos(redboot)移植剖析

    發布: 2008-8-04 10:59 | 作者: 網絡轉載 | 來源: 網絡轉載 | 查看: 341次 | 進入軟件測試論壇討論

    領測軟件測試網

    不同平臺之間的移植(CPU相同,硬件平臺不同) mypath是ecos的安裝目錄 mypath/ecos/package/ecos.db記錄了現有的包(package)和目標板(target)描述.

    一個target包含若干的package,target的描述會出現在configtool的templete的選項里。Target里同時指定了包含的package。照貓畫虎的添加上自己的package和target后就可以在configtool的templete里看到。

    Ecos的軟件分了若干的模塊,移植工作主要在他的hal層進行(包含在package/hal路徑下),所謂hal(硬件抽象層)就是把和硬件相關的軟件湊到一起,因為其他大部分代碼使用C和C++,和硬件都是無關的,所以主要研究這一部分代碼就可以進行移植,實際工作更加簡單,因為ecos的HAL還分了幾層,Common HAL, Architecture HAL,Variant HAL,Platform HAL,這幾個層次同樣可以在軟件結構上找到對應關系,以三星的snds平臺為例,首先在hal路徑下可以看到common目錄,/hal/arm/arch/目錄,以及/hal/arm/snds/目錄。這和上面的幾層基本是對應的,當然這里這里面可以認為Variant HAL,Platform HAL合并了, 值得注意的是以上每個目錄下的cdl目錄下的cdl文件,打開configtool,在build->templete中選擇samsung snds平臺和redboot包后,可以看到出現相應的選項,其中有一個eCOSHal選項,該選項展開以后有ARMarchitecture,再展開以后還有SamsungSNDS evaluation board 選項,展開后同樣有諸多選項,分別打開以上目錄中的cdl文件,和這些選項對照,發現每一層的選項和每一層的CDL文件中的描述一一對應(雖然不知道CDL文件的語法,但對應關系還是很清晰)?梢哉f每一層之間相同的軟件模塊都有很大的借鑒,(一般可以直接COPY,然后根據不同之處作相應的改動即可)。對于現代的CPU,因為是ARM體系的,所以位置和arm下其他cpu模塊是并列的,同時可以大量借鑒。

    另一個問題是configtool中的選項如何在代碼中實現,其實研究一下可以發現大部分選項對應一個宏定義,而選項的值將被用作代替這個宏,當然選項中還有對一些文件的選擇,將在編譯鏈接的時候用到。

    通過配置文件配置完畢后,會被要求保存ecc文件,同時會在該目錄下生成一個build目錄和install目錄,build目錄存放最終需要編譯的代碼,這時再看hal目錄,發現每一層只剩下和自己平臺相關的文件了。

    Install目錄下存放了生成的各種格式的可執行的文件和編譯鏈接所需要的庫文件和頭文件。

    對于需要修改和研究的文件,在ecos的文檔中有一個相應的列表,因為現代CPU是ARM核,所以對以下文件研究即可。

    Variant HAL
    Some variant HALs may add extra files for variant specific serial drivers, or for handling interrupts/exceptions if it makes sense.

    Note that these files may be mostly empty if the CPU variant can be controlled by the generic architecture macros. The definitions present are only conditionally defined - if the equivalent platform headers provide the definitions, those override the variant definitions.

    File Description
    include/var_arch.h Saved register frame format, various thread, register and stack related macros.
    include/var_cache.h Cache related macros.
    include/var_intr.h Interrupt related macros.
    include/var_regs.h Extra register definitions for the CPU variant. include/variant.inc Various assembly macros used during system initialization.
    src/var_intr.c Interrupt functions if necessary.
    src/var_misc.c hal_variant_init function and any necessary extra functions.
    src/variant.S Interrupt handler table definition.
    src/<arch>_<variant>.ld Linker macros.

    Platform HAL
    Extras files may be added for platform specific serial drivers. Extra files for handling interrupts and exceptions will be present if it makes sense.

    File Description

    include/hal_diag.h Defines functions used for HAL diagnostics output. This would normally be the ROM calling interface wrappers, but may also be the low-level IO functions themselves, saving a little overhead.
    include/platform.inc Platform initialization code. This includes memory controller, vectors, and monitor initialization. Depending on the architecture, other things may need defining here as well: interrupt decoding, status register initialization value, etc.
    include/plf_cache.h Platform specific cache handling.
    include/plf_intr.h Platform specific interrupt handling.
    include/plf_io.h PCI IO definitions and macros. May also be used to override generic HAL IO macros if the platform endianness differs from that of the CPU.
    include/plf_stub.h Defines stub initializer and board reset details. src/hal_diag.c May contain the low-level device drivers. But these may also reside in plf_stub.c
    src/platform.S Memory controller setup macro, and if necessary interrupt springboard code.
    src/plf_misc.c Platform initialization code.
    src/plf_mk_defs.c Used to export definitions from C header files to assembler header files.
    src/plf_stub.c Platform specific stub initialization and possibly the low-level device driver.

    以上20多個文件有一些也是不需要的,反正基本結構了解了以后,心理就能踏實一點了,呵呵

    另外,看文檔的過程中順便看了看ecos的特性,應該說還是很不錯,文件系統,協議棧都很全,還支持SMP,同樣是實時,并且源代碼開放,免費。比起那個ucos是強大多了,唯一缺陷是移植和使用復雜一點(但可移植性絕對強),而且國內介紹的書籍也不多,實在是可惜。希望借著這次機會能有所推廣。

    前面只是基本的剖析,有興趣的還是應該多看文檔,多分析,后面會把看代碼中的心得貼出大家共同學習。 有一個錯誤糾正一下,build目錄下存放的是編譯的目標文件,不是源文件。 redboot和自己的bootloader可以并行,實際上hal_platform_setup.h中實現了平臺的基本初始化,是通過PLATFORM_SETUP1這個宏實現的。

    如果沒有硬件板子,可以先簡單做一個軟件仿真,應用ADW調試工具,在option選項中選擇configure----ARMulate-----configure,在其中設置必要的微處理器內核,和一些其他選項,[適應你的cpu] 就可以仿真了。[我的程序是在SDT環境下做的]

    ARMulate,是arm公司提供的軟件仿真調試代理。在清華那本《ARM體系結構與編程中有介紹〉。

    再說一下Redboot,雖然現代可能已經移植好了,但是我們的目的是學習嘛,所以我就把我針對s344b0x01移植時的相關代碼和步驟說一下,讓大家批評指正。

    首先:改動ecos.db增加我的packages和target
    package CYGPKG_HAL_ARM_HLAS {
    alias { "Dongsin HLAS" hal_arm_hlas arm_hlas_hal}
    directory hal/arm/hlas
    script hal_arm_hlas.cdl
    hardware description " The HLAS HAL package provides the support needed to un eCos on a Dongsin HLAS eval board" }
    target hlas {
    alias { "Dongsin HLAS" HLAS hlas hlas100}
    packages { CYGPKG_HAL_ARM CYGPKG_HAL_ARM_HLAS }
    enable { CYGHWR_HAL_ARM_LITTLEENDIAN}
    description " The hlas target provides the packages needed to run eCos on a Dongsin HLAS eval board." }
    然后,修改我的packages CYGPKG_HAL_ARM_HLAS.CDL 大部分可以參考模板

    三、 定義I/O moacos 在做這部分工作時一定要有耐性,定義要按照模板進行 這塊做的好會給以后的編程帶來方便。

    四、 編寫基本的串口驅動了,

    一直推薦研究這個bootloader是因為ecos的可移植性方面的工作和提供的工具是其他開發源碼bootloader無法相比的,希望能總結出新平臺的移植細節,從而是大家在其他平臺上也可以迅速移植并使用。雖然源代碼有了,有些東西還是應該分析清楚,以配合硬件組連調。作者:知秋一葉

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    TAG: ecos Redboot redboot 剖析 移植


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>