--- title: Lab28: Extend RTOS toc: no ... 預期目標 ------- * 擴展 [`rtenv`` 的功能:引入 `rtenv-plus](https://github.com/embedded2014/rtenv-plus),一個強化的 ``rtenv`` 版本,未來將逐步使其具備商用 RTOS 能力 * 分析 romfs,並實作基本檔案處理 * 複習前幾周的實作技巧 * 整合之前的 unit test rtenv-plus: 強化的 rtenv ------------------------- * 成大資訊系 102 級林哲安同學的最新力作 - 基於 https://github.com/embedded2014/rtenv * 修改項目 - ROM file system offers a read-only file system during compilation - Various build system improvements - Fix memcpy error - Support of block devices - Fix of memory configuration - Introduce event monitor technique to handle interrupts - Efficient I/O encapsulation * 測試方式 - ``git clone git@github.com/embedded2014/rtenv-plus.git`` * 或者 ``git clone https://github.com/embedded2014/rtenv-plus.git`` - ``cd rtenv-plus`` - ``mkdir -p data/rom0`` - ``echo X > data/rom0/X`` # 我們試著在 romfs 放入一個檔名為 "X",內容也是 "X" 的檔案 - ``make`` - ``make qemu`` - 當出現 QEMU 畫面後,在 UART 中輸出 help,預期可見以下: * xxd: Make a hexdump - 在 UART 輸入 ``xxd /X``,可見到以下輸出: * 00000000: 580a X. - 由此可見,[rtenv-plus](https://github.com/embedded2014/rtenv-plus) 提供了一份檔案系統實作,而且可在編譯時期加入到 ``main.bin`` 中。驗證方法: * ``make clean`` * ``echo NCKU > data/rom0/X`` * ``make`` * 用 vim 打開 ``build/main.bin`` 檔案,或者用以下指令確認: - ``strings build/main.bin | grep NCKU`` romfs 實作 ----------- * 程式碼 - src/kernel.c: 註冊 ``romdev_driver`` 和 ``romfs_server`` .. code-block:: prettyprint void first() { if (!fork()) setpriority(0, 0), pathserver(); if (!fork()) setpriority(0, 0), romdev_driver(); if (!fork()) setpriority(0, 0), romfs_server(); - src/romdev.c: Driver - 銜接底層的 block device - src/romfs.c: 檔案系統和相關界面 * 參考資訊 - [Lab21](/embedded/Lab21) - [Lab21 實作程式碼](https://embedded2013.hackpad.com/Lab21-RTOS-shzzlckJ50f) * [Block Devices: Drivers and Files](http://hssl.cs.jhu.edu/~randal/419/lectures/L5.5.BDD.pdf) 參考作業提案 ------------- * 將 Lab25, Lab26, Lab27 開發的程式碼整合到 ``rtenv-plus``,含 unit test 系統 * 利用檔案系統實現 ``ls`` 和 ``cat`` 功能 - ls: 印出檔案系統的目錄和其結構 - cat: 印出指定檔案的內容 * 延伸之前的 unit test,當 ``make check`` 後,我們得以驗證 romfs 的功能並且自動測試 ``ls`` 和 ``cat`` * 試著理解 rtenv-plus 相對 rtenv 具體的改進項目,並以及從中學習 作業繳交方式 ------------- * 更新作業提案到共筆網站: [Lab 28 / 作業共筆](https://embedded2014.hackpad.com/Lab28-Extend-RTOS-5evpv6zmkx1),需要標注自己的 ID * 在 Mar 21 前,將符合作業提案的程式碼,提交到自行 fork 的 repository - https://github.com/embedded2014/rtenv-plus - 注意: 要記得 fork ``rtenv-plus``