版本 73142421c57bf763bd16f634c2a61ac863663ebf
Changes from 73142421c57bf763bd16f634c2a61ac863663ebf to 2836f3bd15f1d91cd18f4e7be34b50fb767b4311
---
title: FreeRTOS (MMU)
categories: embedded, arm, rtos, beaglebone black, am335x, mmu
toc: no
...
協作者
===
* 2015 年春季
- `陳冠任<https://github.com/dani4310>`_, `許士杰<https://github.com/Jayjack0116>`_, `黃睦林<https://github.com/MuLinForest>`_, `孫瑋<https://github.com/saya222777>`_, `涂逸祥<https://github.com/tuition0804>`_
共筆
==
* 2015 年春季
- `hackpad<https://hackpad.com/FreeRTOS-MMU-7T05PYBOFIy>`_
**目錄**
======
* `Beaglebone black 簡介<#Beaglebone black 簡介>`_
* `Beaglebone black 簡介<#Beaglebone-black-簡介>`_
- `硬體簡介<#硬體簡介>`_
- `開機流程<#開機流程>`_
* `FreeRTOS on Beaglebone Black<#FreeRTOS on Beaglebone Black>`_
* `FreeRTOS on Beaglebone Black<#FreeRTOS-on-Beaglebone-Black>`_
- `開發環境<#開發環境>`_
- `實作過程<#實作過程>`_
* `問題討論<#問題討論>`_
`Beaglebone black 簡介<#目錄>`_
===========================
`硬體簡介<#目錄>`_
------------
* Processor: `AM335x 1GHz ARM® Cortex-A8<http://www.ti.com/product/am3358>`_
- 512MB DDR3 RAM
- 4GB 8-bit eMMC on-board flash storage
- 3D graphics accelerator
- NEON floating-point accelerator
- 2x PRU 32-bit microcontrollers
* Connectivity
- USB client for power & communications
- USB host
- Ethernet
- HDMI
- 2x 46 pin headers
* Software Compatibility
- Debian
- Android
- Ubuntu
- Cloud9 IDE on Node.js w/ BoneScript library
- plus much more
.. image:: http://www.circuidipity.com/images/bbb-details3.png
`開機流程<#目錄>`_
------------
當Beaglebone Black(BBB)一上電後,即開始執行ROM裡面的ROM code。再來根據腳位SYSBOOT的值來決定讀取哪裡的MLO檔,預設是讀取板子上eMMC的MLO檔。再來靠MLO讀取u-boot,u-boot再根據文件uEnv.txt載入image或file system。
.. image:: https://c1.staticflickr.com/9/8827/17633638240_e7c3e007a4_o.jpg
若是按住BBB板子上的S2按鍵,根據下圖,會讓SYS_BOOT2變成低電位,使得BBB的ROM code載入MMCSD內的MLO並執行。之後再根據MLO的程式碼來決定要載入什麼檔案執行。在我們第一次實驗時,是利用MLO去載入app並執行。
.. image:: https://c2.staticflickr.com/6/5462/17823806425_3996a193f6_o.png
`FreeRTOS on Beaglebone Black<#目錄>`_
====================================
`開發環境<#目錄>`_
------------
* 主機環境:Ubuntu 14.10、Linux Mint 17
* 開發板:Beaglebone black (Rev C)
* Cross compiler: https://launchpad.net/gcc-arm-embedded/+download 下載並解壓至喜歡的地方
`實作過程<#目錄>`_
------------
**下載程式碼:**
.. code-block:: bash
git clone https://github.com/henfos/BBBFreeRTOS.git
cd BBBFreeRTOS/Demo/AM3359_BeagleBone_GCC
**修改 main.c ,在開頭補上 :**
.. code-block:: c
#include <stdint.h>
**修改 makefile:**
將以下原本的參數
.. code-block:: makefile
CC=/home/henrifo/Nedlastinger/gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gcc
OBJCOPY=/home/henrifo/Nedlastinger/gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-objcopy
ARCH=/home/henrifo/Nedlastinger/gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-ar
改成
.. code-block:: makefile
CC={Cross compiler解壓的路徑}/arm-none-eabi-gcc
OBJCOPY={Cross compiler解壓的路徑}/arm-none-eabi-objcopy
ARCH={Cross compiler解壓的路徑}/arm-none-eabi-ar
**接下來執行make,會產生 rtosdemo-a.bin**
**編寫uEnv.txt讓u-boot根據其而載入rtosdemo-a.bin,內容如下**
.. code-block:: txt
bootcmd=fatload mmc 0 0x80500000 rtosdemo-a.bin; go 0x80500000;
uenvcmd=boot
**將MLO、uEnv.txt、u-boot.img、rtosdemo-a.bin放入MicroSD卡**
**按住BBB的S2鈕並開機**
結果圖如下,可看出FreeRTOS已能初步運作。
.. image:: https://c1.staticflickr.com/1/476/18159470350_95ea35c12d_o.png
**將main.c的3個task,刪減到剩下1個。
將delay的計數器從0x1FFF改成0x3FF0000,增加閃爍時間間隔。
並將serial_puts的function中加入'\\r',將輸出的游標推到每行起始位置。**
結果圖如下,輸出的結果比較清晰且LED的閃爍可以用肉眼察覺。
.. image:: https://c1.staticflickr.com/9/8781/18344147282_2ebf303d4d_o.png